Skip to content

WW-5840 Provide a path-stripped original file name for action-based file uploads - #2116

Open
g0w6y wants to merge 1 commit into
apache:mainfrom
g0w6y:WW-5840-sanitized-upload-filename
Open

g0w6y wants to merge 1 commit into
apache:mainfrom
g0w6y:WW-5840-sanitized-upload-filename

Conversation

@g0w6y

@g0w6y g0w6y commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Fixes WW-5840

UploadedFile.getOriginalName() returns the file name exactly as the client sent it, including any directory part. The framework itself never uses that value as a path (the stored temp file is always UUID-named), but the replacement ActionFileUploadInterceptor/UploadedFilesAware API passes it through unchanged, unlike the legacy pre-7.0 path which stripped it.

  • Adds UploadedFile#getSanitizedOriginalName() (basename only), alongside the existing raw accessor, with javadoc on both making the distinction explicit.
  • Switches the showcase upload actions, which only ever use the name for display, to the sanitised accessor.

Verified: AbstractMultiPartRequestTest gains a benign-marker test proving the raw accessor is unsanitised and the new one is not. Full core: 3742/0 failures (JakartaMultiPartRequestTest 42/42, JakartaStreamMultiPartRequestTest 43/43). apps/showcase changes are mechanical 1-line accessor swaps with no test asserting the exact filename string.

…ile uploads

UploadedFile.getOriginalName() returns the file name exactly as the client
sent it in the multipart Content-Disposition header, including any
directory part. The framework itself never uses that value as a path (the
stored temp file is always UUID-named), but the legacy FileUploadInterceptor
path stripped it via FilenameUtils.getName() before 7.0, and the replacement
ActionFileUploadInterceptor/UploadedFilesAware API passes the raw value
through unchanged.

Adds UploadedFile#getSanitizedOriginalName() (basename only, via
FilenameUtils.getName), alongside the existing raw accessor, with javadoc on
both making the raw/sanitised distinction explicit. The showcase upload
actions, which only ever use the name for display, switch to the sanitised
accessor.

Tests: AbstractMultiPartRequestTest gains a benign-marker test proving the
raw accessor is unsanitised and the new sanitised one is not. Full core
suite: 3742/0 failures (includes JakartaMultiPartRequestTest 42/42,
JakartaStreamMultiPartRequestTest 43/43). apps/showcase changes are
mechanical 1-line accessor swaps with no test asserting the exact filename
string; could not run its own suite in this environment due to an unrelated,
pre-existing local dependency gap in plugins/tiles (struts2-velocity-tools-
view-jakarta never built on this machine), confirmed unrelated to this
change by inspection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant