aperezdc/ngx-fancyindex

Wrong trimming of utf-8 filenames

hempalex opened this issue · 4 comments

If filename is longer than fancyindex_name_length and contains non-latin symbols it would be trimmed in wrong way, in bytes not utf-8 codepoints.

Maybe it should respect charset settings?

Yes, that is a bit unfortunate and the current implementation is overly naïve. While invalid UTF-8 sequences won't break any browser, it does make them show replacement characters (more information in this article).

One option may be to chop off the string at the maximum configured length, and if that point falls in the middle of a multibyte UTF-8 sequence, go back to the latest valid one and trim the bytes from the malformed sequence.

same problem, but an easy workaround is to increase the max length, say, from 50 to 100, so that the long title could be displayed.

I suppose this can be closed now that fancyindex_name_length has been removed and no truncation of the file name happens anymore.

I suppose this can be closed now that fancyindex_name_length has been removed and no truncation of the file name happens anymore.

Indeed, thanks for noticing!