From 6d92ebca454ab2e6533d0b7a08bfe30d20005820 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 23 Apr 2012 17:09:28 +0200 Subject: [PATCH] use native functions of php to parse the string into the Var --- core/js/js.js | 2 +- lib/base.php | 13 ++++++------- lib/helper.php | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index 4abaced1ae0..b4482185509 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -53,7 +53,7 @@ OC={ var isCore=OC.coreApps.indexOf(app)!=-1; var link=OC.webroot; if(file.substring(file.length-3) == 'php' && !isCore){ - link+='/?app=' + app + '&getfile=' + type + '/' + file; + link+='/?app=' + app + '&getfile=' + encodeURI(type + '/' + file); }else{ link+='/'; app+='/'; diff --git a/lib/base.php b/lib/base.php index 4800a426217..559d49ca997 100644 --- a/lib/base.php +++ b/lib/base.php @@ -284,7 +284,7 @@ class OC{ if(file_exists(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE)){ require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE); }else{ - header('404 Not found'); + echo "WTF"; } } @@ -401,12 +401,11 @@ class OC{ self::$REQUESTEDAPP = (isset($_GET['app'])?strip_tags($_GET['app']):'files'); self::$REQUESTEDFILE = $_GET['getfile']; if(substr_count(self::$REQUESTEDFILE, '?') != 0){ - $pos_questionmark = strpos(self::$REQUESTEDFILE, '?'); - $pos_equal = strpos(self::$REQUESTEDFILE, '='); - $pos_and = strpos(self::$REQUESTEDFILE, '?'); - $_GET[substr(self::$REQUESTEDFILE, $pos_questionmark + 1, $pos_equal - $pos_questionmark - 1)] = substr(self::$REQUESTEDFILE, $pos_equal + 1, $pos_and); - self::$REQUESTEDFILE = substr(self::$REQUESTEDFILE, 0, $pos_questionmark); - $_GET['getfile'] = OC::$REQUESTEDFILE; + $file = substr(self::$REQUESTEDFILE, 0, strpos(self::$REQUESTEDFILE, '?')); + $param = substr(self::$REQUESTEDFILE, strpos(self::$REQUESTEDFILE, '?') + 1); + parse_str($param, $_GET); + self::$REQUESTEDFILE = $file; + $_GET['getfile'] = $file; } self::$REQUESTEDFILE = (isset($_GET['getfile'])?(OC_Helper::issubdirectory(OC::$APPSROOT . '/' . self::$REQUESTEDAPP . '/' . self::$REQUESTEDFILE, OC::$APPSROOT . '/' . self::$REQUESTEDAPP)?self::$REQUESTEDFILE:null):null); } diff --git a/lib/helper.php b/lib/helper.php index 2067190bca7..072a544a40a 100755 --- a/lib/helper.php +++ b/lib/helper.php @@ -45,7 +45,7 @@ class OC_Helper { $app = substr($app, 0, strlen($app) - 1); } $urlLinkTo = OC::$APPSWEBROOT . '/?app=' . $app; - $urlLinkTo .= ($file!='index.php')?'&getfile=' . $file:''; + $urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):''; } else{ $urlLinkTo = OC::$WEBROOT . '/' . $app . $file; -- 2.39.5