diff options
| author | Peter Lejeck <peter.lejeck@gmail.com> | 2014-01-18 08:41:21 +0100 |
|---|---|---|
| committer | Peter Lejeck <peter.lejeck@gmail.com> | 2014-01-18 08:41:21 +0100 |
| commit | b753bc91a39deb93970706dbd4abce84bbe3bb46 (patch) | |
| tree | 64ac7b443fa4d9455c9edabdb87653c037d88548 /static/upload.php | |
| parent | 70707eb27ac6b556ac910db5a1c7f0e4ea38647d (diff) | |
Add double-dot handling. Fixes #1
Diffstat (limited to 'static/upload.php')
| -rw-r--r-- | static/upload.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/static/upload.php b/static/upload.php index 3da7174..5fd553e 100644 --- a/static/upload.php +++ b/static/upload.php @@ -10,11 +10,20 @@ include_once 'includes/database.inc.php'; * @return string */ function generate_name ($file) { + global $doubledots; // We start at N retries, and --N until we give up $tries = POMF_FILES_RETRIES; // We rip out the extension using pathinfo - // TODO: figure out a solution for .tar.gz and similar files? This has now been ghetto fixed, read below! $ext = pathinfo($file->name, PATHINFO_EXTENSION); + + // And if we realize it's actually a doubledot + // we just override $ext + $revname = strrev($file->name); + foreach ($doubledots as $ddot) { + if (stripos($revname, $ddot) === 0) { + $ext = strrev($ddot); + } + } do { // If we run out of tries, throw an exception. Should be caught and JSONified. if ($tries-- == 0) throw new Exception('Gave up trying to find an unused name'); |
