Classi per la configurazione upload
Cristiano Magro
2019-08-27 fc5cefc7766fd5d1e2699c12184147ffe17afc9c
Try to fix problema UTF-8 con carattere non stampabile

viene confuso con \xA0 e la "à"
2 files modified
7 ■■■■ changed files
src/Vola/UploadFile/Filename.php 4 ●●● patch | view | raw | blame | history
tests/Vola/UploadFile/FilenameTest.php 3 ●●●●● patch | view | raw | blame | history
src/Vola/UploadFile/Filename.php
@@ -25,12 +25,14 @@
    public function filter($filename, $beautify = true)
    {
        // sanitize filename
        $filename = preg_replace(
            '~
        [<>:"/\\|?*]|            # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
        [\x00-\x1F]|             # control characters http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
        [\x7F\xA0\xAD]|          # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
//        [\x7F\xA0\xAD]|          # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
        [\x7F\xAD]|          # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN
        [#\[\]@!$&\'()+,;=]|     # URI reserved https://tools.ietf.org/html/rfc3986#section-2.2
        [{}^\~`]                 # URL unsafe characters https://www.ietf.org/rfc/rfc1738.txt
        ~x',
tests/Vola/UploadFile/FilenameTest.php
@@ -27,6 +27,9 @@
            ['../ciCcio-- a.zip', 'ciccio-a.zip'],
            ['../../ciccio.ZIP.zip', 'ciccio.zip.zip'],
            ['ciccioò.zip', 'ciccioò.zip'],
            ['ciccioà.zip', 'ciccioà.zip'],
            ['à.zip', 'à.zip'],
            ['àèéòùì', 'àèéòùì'],
            ['', ''],
        ];
    }