From b753bc91a39deb93970706dbd4abce84bbe3bb46 Mon Sep 17 00:00:00 2001 From: Peter Lejeck Date: Fri, 17 Jan 2014 23:41:21 -0800 Subject: Add double-dot handling. Fixes #1 --- static/upload.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'static/upload.php') 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'); -- cgit v1.2.3