mirror of
https://github.com/filegator/filegator.git
synced 2025-08-12 06:44:09 +02:00
fix for filename sanitize/cut
This commit is contained in:
@@ -137,15 +137,6 @@ class Tmpfs implements Service, TmpfsInterface
|
||||
);
|
||||
|
||||
// maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
|
||||
$ext = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
|
||||
return mb_strcut(
|
||||
pathinfo($filename, PATHINFO_FILENAME),
|
||||
0,
|
||||
255 - ($ext ? strlen($ext) + 1 : 0),
|
||||
(string) mb_detect_encoding($filename)
|
||||
).(
|
||||
$ext ? '.'.$ext : ''
|
||||
);
|
||||
return mb_substr($filename, 0, 255);
|
||||
}
|
||||
}
|
||||
|
@@ -157,5 +157,12 @@ class TmpfsTest extends TestCase
|
||||
|
||||
// with invalid chars
|
||||
$this->assertEquals('..--s-u---pe----rm---an-.t-xt..--', $this->invokeMethod($this->service, 'sanitizeFilename', ["../\\s\"u<:>pe////rm?*|an\\.t\txt../;"]));
|
||||
|
||||
// oversized
|
||||
$this->assertEquals(
|
||||
'123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345',
|
||||
$this->invokeMethod($this->service, 'sanitizeFilename', [
|
||||
'1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user