Making it so OpenLayers.Util.getParameters doesn't fail with improperly encoded query string parameter names or values. We expect parameter names and values to be encoded according to RFC 3986 (http://labs.apache.org/webarch/uri/rfc/rfc3986.html). However, there are cases where browsers will not use utf-8 character encoding in generating a URL. In these cases, the unescape function provides a fallback that tries to use the ISO Latin character set. This may not always be a good second assumption, but it is better than failing to load the library when the first assumption fails. r=ahocevar (closes #2821)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10771 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2010-09-17 16:48:11 +00:00
parent bb71632848
commit b8feb3c22e
2 changed files with 32 additions and 5 deletions
+18 -4
View File
@@ -1062,11 +1062,25 @@ OpenLayers.Util.getParameters = function(url) {
for(var i=0, len=pairs.length; i<len; ++i) {
var keyValue = pairs[i].split('=');
if (keyValue[0]) {
var key = decodeURIComponent(keyValue[0]);
var value = keyValue[1] || ''; //empty string if no value
//decode individual values (being liberal by replacing "+" with " ")
value = decodeURIComponent(value.replace(/\+/g, " ")).split(",");
var key = keyValue[0];
try {
key = decodeURIComponent(key);
} catch (err) {
key = unescape(key);
}
// being liberal by replacing "+" with " "
var value = (keyValue[1] || '').replace(/\+/g, " ");
try {
value = decodeURIComponent(value);
} catch (err) {
value = unescape(value);
}
// follow OGC convention of comma delimited values
value = value.split(",")
//if there's only one value, do not return as array
if (value.length == 1) {