[Pkg-owncloud-commits] [owncloud] 37/74: Use md5() of the original name instead of uniqid() for slugifying

David Prévot taffit at moszumanska.debian.org
Tue Dec 2 22:04:36 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit baf8d8433fe986ab61913e1209b6e7734ac0e80d
Author: Joas Schilling <nickvergessen at gmx.de>
Date:   Mon Aug 25 14:29:07 2014 +0200

    Use md5() of the original name instead of uniqid() for slugifying
    
    Previously we used uniqid() here.
    However this means that the behaviour is not reproducable, so
    when uploading files into a "empty" folder, the folders name is
    different.
    
    If there would be a md5() hash collition, the deduplicate check
    will spot this and append an index later, so this should not be
    a problem.
    
    Fix #6722
---
 lib/private/files/mapper.php | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/private/files/mapper.php b/lib/private/files/mapper.php
index 93f6f9b..94dda80 100644
--- a/lib/private/files/mapper.php
+++ b/lib/private/files/mapper.php
@@ -216,6 +216,7 @@ class Mapper
 	 * @return string
 	 */
 	private function slugify($text) {
+		$originalText = $text;
 		// replace non letter or digits or dots by -
 		$text = preg_replace('~[^\\pL\d\.]+~u', '-', $text);
 
@@ -237,7 +238,17 @@ class Mapper
 		$text = preg_replace('~\.+$~', '', $text);
 
 		if (empty($text)) {
-			return uniqid();
+			/**
+			 * Item slug would be empty. Previously we used uniqid() here.
+			 * However this means that the behaviour is not reproducible, so
+			 * when uploading files into a "empty" folder, the folders name is
+			 * different.
+			 *
+			 * If there would be a md5() hash collision, the deduplicate check
+			 * will spot this and append an index later, so this should not be
+			 * a problem.
+			 */
+			return md5($originalText);
 		}
 
 		return $text;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list