mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Support for commas in URLs processed by Requirements and jQuery.ondemand (which uses commas to serialise its dependency data into HTTP headers)
This commit is contained in:
parent
5ec6aa532c
commit
6dd3dc9f59
@ -15,6 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
(function($){
|
(function($){
|
||||||
|
|
||||||
|
var decodePath = function(str) {
|
||||||
|
return str.replace(/%2C/g,',').replace(/\&/g, '&');
|
||||||
|
};
|
||||||
|
|
||||||
$.extend({
|
$.extend({
|
||||||
|
|
||||||
// loaded files list - to protect against loading existed file again (by PGA)
|
// 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){
|
requireCss : function(styleUrl, media){
|
||||||
@ -89,10 +93,10 @@
|
|||||||
for(var i=0;i<cssIncludes.length;i++) {
|
for(var i=0;i<cssIncludes.length;i++) {
|
||||||
// Syntax: "URL:##:media"
|
// Syntax: "URL:##:media"
|
||||||
if(cssIncludes[i].match(/^(.*):##:(.*)$/)) {
|
if(cssIncludes[i].match(/^(.*):##:(.*)$/)) {
|
||||||
$.requireCss(RegExp.$1, RegExp.$2);
|
$.requireCss(decodePath(RegExp.$1), RegExp.$2);
|
||||||
// Syntax: "URL"
|
// Syntax: "URL"
|
||||||
} else {
|
} else {
|
||||||
$.requireCss(cssIncludes[i]);
|
$.requireCss(decodePath(cssIncludes[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,8 +106,9 @@
|
|||||||
if(xhr.getResponseHeader && xhr.getResponseHeader('X-Include-JS')) {
|
if(xhr.getResponseHeader && xhr.getResponseHeader('X-Include-JS')) {
|
||||||
var jsIncludes = xhr.getResponseHeader('X-Include-JS').split(',');
|
var jsIncludes = xhr.getResponseHeader('X-Include-JS').split(',');
|
||||||
for(var i=0;i<jsIncludes.length;i++) {
|
for(var i=0;i<jsIncludes.length;i++) {
|
||||||
if(!$.isItemLoaded(jsIncludes[i])) {
|
var jsIncludePath = decodePath(jsIncludes[i]);
|
||||||
newJsIncludes.push(jsIncludes[i]);
|
if(!$.isItemLoaded(jsIncludePath)) {
|
||||||
|
newJsIncludes.push(jsIncludePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,14 +726,19 @@ class Requirements_Backend {
|
|||||||
|
|
||||||
foreach(array_diff_key($this->javascript, $this->blocked) as $file => $dummy) {
|
foreach(array_diff_key($this->javascript, $this->blocked) as $file => $dummy) {
|
||||||
$path = $this->path_for_file($file);
|
$path = $this->path_for_file($file);
|
||||||
if($path) $jsRequirements[] = $path;
|
if($path) {
|
||||||
|
$jsRequirements[] = str_replace(',', '%2C', $path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->addHeader('X-Include-JS', implode(',', $jsRequirements));
|
$response->addHeader('X-Include-JS', implode(',', $jsRequirements));
|
||||||
|
|
||||||
foreach(array_diff_key($this->css,$this->blocked) as $file => $params) {
|
foreach(array_diff_key($this->css,$this->blocked) as $file => $params) {
|
||||||
$path = $this->path_for_file($file);
|
$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));
|
$response->addHeader('X-Include-CSS', implode(',', $cssRequirements));
|
||||||
|
Loading…
Reference in New Issue
Block a user