From 3543c6de939c52517f590300b6d4289dc3a785ff Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Mon, 28 Nov 2011 20:29:39 +0100
Subject: [PATCH] deprecated 3rd parameter of cleanID() FS#2377

For some reason trailing/leading underscores were allowed when uploading
files. But the rest of the code (eg. listing or downloading files) never
supported this. This patch removes this special case for uploading files
to streamline ID cleaning of pages and media files.
---
 inc/media.php     | 2 +-
 inc/pageutils.php | 4 ++--
 lib/exe/ajax.php  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/inc/media.php b/inc/media.php
index 9d3e90a54..07351e48b 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -332,7 +332,7 @@ function media_save($file, $id, $ow, $auth, $move) {
     global $lang, $conf;
 
     // get filename
-    $id   = cleanID($id,false,true);
+    $id   = cleanID($id);
     $fn   = mediaFN($id);
 
     // get filetype regexp
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 31b5f9ff9..151fa5987 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -92,7 +92,7 @@ function getID($param='id',$clean=true){
  * @author Andreas Gohr <andi@splitbrain.org>
  * @param  string  $raw_id    The pageid to clean
  * @param  boolean $ascii     Force ASCII
- * @param  boolean $media     Allow leading or trailing _ for media files
+ * @param  boolean $media     DEPRECATED
  */
 function cleanID($raw_id,$ascii=false,$media=false){
     global $conf;
@@ -132,7 +132,7 @@ function cleanID($raw_id,$ascii=false,$media=false){
     //clean up
     $id = preg_replace($sepcharpat,$sepchar,$id);
     $id = preg_replace('#:+#',':',$id);
-    $id = ($media ? trim($id,':.-') : trim($id,':._-'));
+    $id = trim($id,':._-');
     $id = preg_replace('#:[:\._\-]+#',':',$id);
     $id = preg_replace('#[:\._\-]+:#',':',$id);
 
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index f8d62cb57..8edd559d6 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -257,7 +257,7 @@ function ajax_mediaupload(){
         $id = $_GET['qqfile'];
     }
 
-    $id = cleanID($id, false, true);
+    $id = cleanID($id);
 
     $NS = $_REQUEST['ns'];
     $ns = $NS.':'.getNS($id);
-- 
GitLab