arturobernalg opened a new pull request, #603:
URL: https://github.com/apache/jspwiki/pull/603

   Follow-up of #597 and #602.
   
   The check for the name "." in #602 runs before the path is cut at the last 
slash and before the name is trimmed, so names such as "a/.", "./.", "../." and 
"/." still reach the provider as "." (a name with a leading or trailing space 
does too).
   
   On a running wiki (master with #602 merged, Tomcat 10.1), after a first 
attachment had created the directory of the page, uploading a file named "a/." 
wrote 1.bin and attachment.properties directly in the directory of the page 
instead of in a directory of its own. The cause is the migration code in 
BasicAttachmentProvider.findAttachmentDir: when the directory "<name>-dir" does 
not exist it falls back to the plain name, and "." is always the directory of 
the page.
   
   This change:
   - validateFileName checks, after cutting the path and trimming, that the 
name is not made only of dots.
   - findAttachmentDir verifies that the directory of an attachment is a direct 
child of the directory of its page, whatever the name, and raises a 
ProviderException otherwise.
   
   Tests: AttachmentNameDotSegmentTest (the names above are refused; ordinary 
names and ".." behave as before) and 
BasicAttachmentProviderTest.testAttachmentNamedWithDotsDoesNotLeaveItsDirectory.
 Full "mvn clean package" passes. With this change on a running wiki the same 
uploads create no file outside "<name>-dir".
   
   https://claude.ai/code/session_01BrsHTcHemouztMgt7JzhEZ


-- 
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]

Reply via email to