Announcement

Collapse
No announcement yet.

Extend allowedFileTypes in attachment or make config parameter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extend allowedFileTypes in attachment or make config parameter



    Some email pictures imported with types
    'image/jpg',
    'application/octet-stream'
    and then hot shown.

    Please extend list of allowed types or make config parameter
    Attached Files

  • #2
    And another one:

    Add
    Code:
    strtolower($fileType)
    Some attachments imported like image/PNG

    Comment


    • #3
      I added strtolower in attachment import.

      I don't think it's right to enable application/octet-stream for image rendering.

      Comment


      • #4
        It may be more correct to focus on exif_imagetype()?

        or use

        $file_info = new finfo(FILEINFO_MIME_TYPE);
        $mime_type = $file_info->buffer($entity->get('contents'));


        Mime type and extension are not the correct path to determine the file type.
        Last edited by dimyy; 06-01-2021, 03:09 PM.

        Comment


        • #5
          > Mime type and extension are not the correct path to determine the file type.

          I don't think that checking mime-type is not a correct way. The type can be not recognizable by it contents. Maybe we need to use both methods, use finfo as a backup mechanism for types like application/octet-stream. I'm not sure.

          If a file does not contain a mime-type in its contents, there's no reliable way to know its type other than from a body-part header and an extension (we don't use). All methods are just guessing.

          From wiki:

          An associated file is the mime.types file, which associates filename extensions with a MIME type. If the MIME type is properly set, this is unnecessary, but MIME types may be incorrectly set, or set to a generic type such as application/octet-stream, and mime.types allows one to fall back on the extension in these cases. Similarly, since many file systems do not store MIME type information, but instead rely on the filename extension, a mime.types file is frequently used by web servers to determine MIME type.

          Could you provide any email (original) with an application/octet-stream image so I could test the import.
          Last edited by yuri; 06-01-2021, 04:00 PM.

          Comment


          • dimyy
            dimyy commented
            Editing a comment
            In private message
        Working...
        X