Class FileUploadUtil

java.lang.Object
io.netty.handler.codec.http.multipart.FileUploadUtil

final class FileUploadUtil extends Object
  • Constructor Details

    • FileUploadUtil

      private FileUploadUtil()
  • Method Details

    • hashCode

      static int hashCode(FileUpload upload)
    • equals

      static boolean equals(FileUpload upload1, FileUpload upload2)
    • compareTo

      static int compareTo(FileUpload upload1, FileUpload upload2)
    • validateFileNameForMultiPart

      static String validateFileNameForMultiPart(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 String validateContentTypeForMultiPart(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(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(String contentType, boolean throwIfInvalid)