• Resolved Li-An

    (@li-an)


    Hello, I noticed a strange thing. A file named ??ELECOM.M-HT1URBK-boutons.cote.gauche.jpg has been renamed ??ELECOM.M-HT1URBK-boutons.cote_.gauche.jpg after upload. Impossible to explain why there is a _ showing.

Viewing 4 replies - 1 through 4 (of 4 total)
  • It’s called a sanitized file name. When you upload a file, WP checks if there are possible not allowed file extensions within(!) the filename, and adds a trailing underscore to that part of the file name.

    Here the “.cote” is such a not allowed file extensions, so it is sanitized to “.cote_”

    See lines 2079-2099 of https://developer.www.ads-software.com/reference/functions/sanitize_file_name/
    (“Loop over any intermediate extensions. Postfix them with a trailing underscore if they are a 2 – 5 character long alpha string not in the allowed extension list.”)

    Thread Starter Li-An

    (@li-an)

    So I?suppose it’s relative of the length of the word after a “.”. Too small and it’s considered as a possible file extension.

    Yes, correct.
    Any “.” followed by 2-5 letters (a-z, A-Z) will get an “_“.
    But only if those detected possible file extension is not in the list of the allowed extension.

    So an uploaded file with the name
    test.exe.pdf.a.ab.abc.abcd.abcde.abcdef.png
    will become
    test.exe_.pdf.a.ab_.abc_.abcd_.abcde_.abcdef.png

    In detail:

    • .exe: not allowed → becomes .exe_
    • .pdf: allowed
    • .a and .abcdef: not detected as extensions
    • .ab, .abc, .abcd, .abcde: not allowed → _ added
    Thread Starter Li-An

    (@li-an)

    Thanks for these clear explanations.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.