Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUGFIX Support for commas in URLs processed by Requirements and jQuer…

…y.ondemand (which uses commas to serialise its dependency data into HTTP headers)
  • Loading branch information...
commit 6dd3dc9f591327376207aade88a249a80016d866 1 parent 5ec6aa5
@chillu chillu authored
View
15 javascript/jquery-ondemand/jquery.ondemand.js
@@ -15,6 +15,10 @@
*/
(function($){
+ var decodePath = function(str) {
+ return str.replace(/%2C/g,',').replace(/\&/g, '&');
+ };
+
$.extend({
// loaded files list - to protect against loading existed file again (by PGA)
@@ -50,7 +54,7 @@
});
}
- return (this._ondemand_loaded_list[scriptUrl] != undefined);
+ return (this._ondemand_loaded_list[decodePath(scriptUrl)] != undefined);
},
requireCss : function(styleUrl, media){
@@ -89,10 +93,10 @@
for(var i=0;i<cssIncludes.length;i++) {
// Syntax: "URL:##:media"
if(cssIncludes[i].match(/^(.*):##:(.*)$/)) {
- $.requireCss(RegExp.$1, RegExp.$2);
+ $.requireCss(decodePath(RegExp.$1), RegExp.$2);
// Syntax: "URL"
} else {
- $.requireCss(cssIncludes[i]);
+ $.requireCss(decodePath(cssIncludes[i]));
}
}
}
@@ -102,8 +106,9 @@
if(xhr.getResponseHeader && xhr.getResponseHeader('X-Include-JS')) {
var jsIncludes = xhr.getResponseHeader('X-Include-JS').split(',');
for(var i=0;i<jsIncludes.length;i++) {
- if(!$.isItemLoaded(jsIncludes[i])) {
- newJsIncludes.push(jsIncludes[i]);
+ var jsIncludePath = decodePath(jsIncludes[i]);
+ if(!$.isItemLoaded(jsIncludePath)) {
+ newJsIncludes.push(jsIncludePath);
}
}
}
View
9 view/Requirements.php
@@ -726,14 +726,19 @@ function include_in_response(SS_HTTPResponse $response) {
foreach(array_diff_key($this->javascript, $this->blocked) as $file => $dummy) {
$path = $this->path_for_file($file);
- if($path) $jsRequirements[] = $path;
+ if($path) {
+ $jsRequirements[] = str_replace(',', '%2C', $path);
+ }
}
$response->addHeader('X-Include-JS', implode(',', $jsRequirements));
foreach(array_diff_key($this->css,$this->blocked) as $file => $params) {
$path = $this->path_for_file($file);
- if($path) $cssRequirements[] = isset($params['media']) ? "$path:##:$params[media]" : $path;
+ if($path) {
+ $path = str_replace(',', '%2C', $path);
+ $cssRequirements[] = isset($params['media']) ? "$path:##:$params[media]" : $path;
+ }
}
$response->addHeader('X-Include-CSS', implode(',', $cssRequirements));
Please sign in to comment.
Something went wrong with that request. Please try again.