arturobernalg opened a new pull request, #653:
URL: https://github.com/apache/jspwiki/pull/653
Part of JSPWIKI-1310. This pull request builds on #589, #590, #645, #646 and
#650, so it shows their commits until they are merged; the new commit is the
last one.
It adds GET /api/v1/pages/{name}/attachments/{file}, to download the content
of an attachment of a page the caller may view. The version parameter selects a
version of the attachment.
- The content is always sent as a download (Content-Disposition: attachment)
with X-Content-Type-Options: nosniff, never inline, because an attachment can
be a page with script and the API answers on the origin of the wiki. The type
is the one the server knows for the extension, or application/octet-stream.
- The permission to view is checked on the page and on the attachment,
before anything is read. A missing page or attachment is 404, a name that
leaves the directory is 400, and the errors are JSON like in the rest of the
API.
- AttachmentServlet.encodeFileName is made public, so that the file name in
the header is written the same way as by the attachment servlet.
- openapi.yaml describes it, and ApiV1ServletTest has nine new tests:
content, type, length and headers, a web page as attachment, a version, 404 for
the attachment and for the page, 401 without sending the content, 400 for a bad
file name and a bad version.
I also ran it on a Tomcat 10.1 with the war of this branch: the latest
version and version 1 of an attachment come back with the right bytes, an HTML
attachment is a download, and the errors are the JSON ones.
ChangeLog.md is updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]