From 946dec94154ba3e5f7111db9e0fc69b8f3d4f640 Mon Sep 17 00:00:00 2001 From: Justin Brewer Date: Sun, 11 Aug 2013 17:52:38 -0500 Subject: [PATCH] readdir is not guaranteed to be in order readdir's ordering is filesystem-dependent. On many systems, that means it might as well be random. People uploading archives will reasonably expect the files to appear in alphabetical order, so we should make sure they do. --- ext/handle_archive/main.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/handle_archive/main.php b/ext/handle_archive/main.php index fd57e20c..a01589f8 100644 --- a/ext/handle_archive/main.php +++ b/ext/handle_archive/main.php @@ -74,7 +74,14 @@ class ArchiveFileHandler extends Extension { $list = ""; $dir = opendir("$base/$subdir"); - while($filename = readdir($dir)) { + + $files = array(); + while($f = readdir($dir)) { + $files[] = $f; + } + sort($files); + + foreach($files as $filename) { $fullpath = "$base/$subdir/$filename"; if(is_link($fullpath)) {