Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@ public interface UploadedFile extends Serializable {
String getName();

/**
* The raw file name submitted by the client -- <strong>untrusted input</strong>. It may contain
* directory-traversal sequences or drive/UNC prefixes and must not be used to build a
* filesystem path. See {@link #getOriginalBaseName()}.
* The file name as sent by the client, unmodified; it may include a directory part, so do not
* use it to build a filesystem path. See {@link #getOriginalBaseName()}.
*
* @return original file name from upload source, exactly as the client supplied it
* @return original file name from upload source
*/
String getOriginalName();

/**
* The last path segment of {@link #getOriginalName()}, intended for display. It is still
* client-controlled and may be empty, {@code ..}, or otherwise unsafe, so validate it before
* using it in a filesystem path.
* The last path segment of {@link #getOriginalName()}, intended for display. It may be empty,
* {@code ..}, or keep a drive prefix such as {@code C:}, so validate it before using it in a
* filesystem path.
*
* @return the last path segment of {@link #getOriginalName()}
* @since 7.6.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
* this.uploadedFile = uploadedFiles.get(0);
* this.fileName = uploadedFile.getName();
* this.contentType = uploadedFile.getContentType();
* // getOriginalName() is untrusted client input; getOriginalBaseName() is the basename, for display
* // getOriginalBaseName() keeps only the part of the client's file name after the last / or \
* this.originalName = uploadedFile.getOriginalBaseName();
* }
* }
Expand Down
Loading