aboutsummaryrefslogtreecommitdiff
path: root/engine/handlers
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-13 19:30:44 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-13 19:30:44 +0000
commitd87b6ffe7312888d109428e6a939f33394549677 (patch)
treed9211c16c9ac3bb646b0049cc54eda56a11af81c /engine/handlers
parent388d8405bb10b3b2107629f8cd4133bff3a7693c (diff)
downloadelgg-d87b6ffe7312888d109428e6a939f33394549677.tar.gz
elgg-d87b6ffe7312888d109428e6a939f33394549677.tar.bz2
Fixes #3331. Changed cache schema to allow for JS/CSS views with slashes and dots.
git-svn-id: http://code.elgg.org/elgg/trunk@8986 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/handlers')
-rw-r--r--engine/handlers/cache_handler.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/engine/handlers/cache_handler.php b/engine/handlers/cache_handler.php
index 05c35171b..7d6f42dc3 100644
--- a/engine/handlers/cache_handler.php
+++ b/engine/handlers/cache_handler.php
@@ -3,7 +3,7 @@
* Cache handler.
*
* External access to cached CSS and JavaScript views. The cached file URLS
- * should be of the form: cache/<type>/<view>/<viewtype>/<unique_id> where
+ * should be of the form: cache/<type>/<viewtype>/<name/of/view>.<unique_id>.<type> where
* type is either css or js, view is the name of the cached view, and
* unique_id is an identifier that is updated every time the cache is flushed.
* The simplest way to maintain a unique identifier is to use the lastcache
@@ -50,13 +50,16 @@ if (!$request || !$simplecache_enabled) {
echo 'Cache error: bad request';
exit;
}
-$request = explode('/', $request);
+// testing showed regex to be marginally faster than array / string functions over 100000 reps
+// it won't make a difference in real life and regex is easier to read.
+// <type>/<viewtype>/<name/of/view.and.dots>.<ts>.<type>
+$regex = '|([^/]+)/([^/]+)/(.+)\.([^\.]+)\.([^.]+)$|';
+preg_match($regex, $request, $matches);
-//cache/<type>/<view>/<viewtype>/
-$type = $request[0];
-$view = $request[1];
-$viewtype = $request[2];
+$type = $matches[1];
+$viewtype = $matches[2];
+$view = $matches[3];
switch ($type) {
case 'css':