Class FileUploadUtil


  • final class FileUploadUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FileUploadUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean checkContentTypeForMultiPart​(java.lang.String contentType, boolean throwIfInvalid)  
      (package private) static int compareTo​(FileUpload upload1, FileUpload upload2)  
      (package private) static boolean equals​(FileUpload upload1, FileUpload upload2)  
      (package private) static int hashCode​(FileUpload upload)  
      (package private) static boolean isContentTypeForMultiPartValid​(java.lang.String contentType)
      Determine if the given content type value is syntactically valid and well-formed.
      (package private) static java.lang.String validateContentTypeForMultiPart​(java.lang.String contentType)
      Control characters and the DEL character are either disallowed or strongly discouraged in the Content-Type.
      (package private) static java.lang.String validateFileNameForMultiPart​(java.lang.String filename)
      Control characters, the DEL character, double-quote, and backslash are either disallowed or strongly discouraged, depending on which multipart/form-data specification you read.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileUploadUtil

        private FileUploadUtil()
    • Method Detail

      • hashCode

        static int hashCode​(FileUpload upload)
      • validateFileNameForMultiPart

        static java.lang.String validateFileNameForMultiPart​(java.lang.String filename)
        Control characters, the DEL character, double-quote, and backslash are either disallowed or strongly discouraged, depending on which multipart/form-data specification you read. This method conservatively rejects all of them, and is used for outbound (encoding) filenames.
        Parameters:
        filename - The filename to check.
        Returns:
        The validated filename, unchanged.
      • validateContentTypeForMultiPart

        static java.lang.String validateContentTypeForMultiPart​(java.lang.String contentType)
        Control characters and the DEL character are either disallowed or strongly discouraged in the Content-Type. Space and tab is allowed except for the first character, quotation and other special characters are allowed.

        The Content-Type value MUST be structured in the form of type/subtype parameters. See RFC 9110 §8.3.1, and RFC 2045 §5.1.

        This is used for multipart encoding, so we refuse to emit a malformed content type.

        Parameters:
        contentType - The Content-Type header value to check.
        Returns:
        The valid Content-Type header value, unchanged.
      • isContentTypeForMultiPartValid

        static boolean isContentTypeForMultiPartValid​(java.lang.String contentType)
        Determine if the given content type value is syntactically valid and well-formed.

        The Content-Type value is valid if it is structured in the form of type/subtype parameters. See RFC 9110 §8.3.1, and RFC 2045 §5.1.

        This is used for multipart decoding, where RFC 2045 §5.2 recommends that syntactically invalid content type values be replaced with a default.

        Parameters:
        contentType - The Content-Type header value to check.
        Returns:
        true if the Content-Type header value is valid, otherwise false.
      • checkContentTypeForMultiPart

        private static boolean checkContentTypeForMultiPart​(java.lang.String contentType,
                                                            boolean throwIfInvalid)