From ecbad2ad1c4a20d04be5aa0455cce117c518d4d9 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sat, 5 May 2012 15:31:27 +0200 Subject: [PATCH] MDL-32683 use slashargument urls for theme javascript files --- lib/outputlib.php | 8 +++++++- theme/javascript.php | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/outputlib.php b/lib/outputlib.php index 48d18220e13..7cd7abe0733 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -775,7 +775,13 @@ class theme_config { $params = array('theme'=>$this->name,'rev'=>$rev); $params['type'] = $inhead ? 'head' : 'footer'; - return new moodle_url($CFG->httpswwwroot.'/theme/javascript.php', $params); + if (!empty($CFG->slasharguments) and $rev > 0) { + $url = new moodle_url("$CFG->httpswwwroot/theme/javascript.php"); + $url->set_slashargument('/'.$this->name.'/'.$rev.'/'.$params['type'], 'noparam', true); + return $url; + } else { + return new moodle_url($CFG->httpswwwroot.'/theme/javascript.php', $params); + } } /** diff --git a/theme/javascript.php b/theme/javascript.php index cfc1eb04877..a7ec470d912 100644 --- a/theme/javascript.php +++ b/theme/javascript.php @@ -32,9 +32,22 @@ define('NO_DEBUG_DISPLAY', true); define('ABORT_AFTER_CONFIG', true); require('../config.php'); // this stops immediately at the beginning of lib/setup.php -$themename = min_optional_param('theme', 'standard', 'SAFEDIR'); -$rev = min_optional_param('rev', 0, 'INT'); -$type = min_optional_param('type', 'head', 'RAW'); +if ($slashargument = min_get_slash_argument()) { + $slashargument = ltrim($slashargument, '/'); + if (substr_count($slashargument, '/') < 2) { + image_not_found(); + } + // image must be last because it may contain "/" + list($themename, $rev, $type) = explode('/', $slashargument, 3); + $themename = min_clean_param($themename, 'SAFEDIR'); + $rev = min_clean_param($rev, 'INT'); + $type = min_clean_param($type, 'SAFEDIR'); + +} else { + $themename = min_optional_param('theme', 'standard', 'SAFEDIR'); + $rev = min_optional_param('rev', 0, 'INT'); + $type = min_optional_param('type', 'head', 'RAW'); +} if ($type !== 'head' and $type !== 'footer') { header('HTTP/1.0 404 not found');