From 041e0e5b66fb3e94ea99b06b24d99b60cf85e169 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 21 Oct 2014 22:37:47 +0200 Subject: [PATCH] Encode everything except a whitelist of special chars see #2406 --- js/id/util.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/id/util.js b/js/id/util.js index 7c96480be..660f164dd 100644 --- a/js/id/util.js +++ b/js/id/util.js @@ -41,7 +41,11 @@ iD.util.stringQs = function(str) { }; iD.util.qsString = function(obj, noencode) { - function softEncode(s) { return s.replace('&', '%26').replace('=', '%3D'); } + function softEncode(s) { + // encode everything except special characters used in certain hash parameters: + // "/" in map states, ":", ",", {" and "}" in background + return encodeURIComponent(s).replace(/(%2F|%3A|%2C|%7B|%7D)/g, decodeURIComponent); + } return Object.keys(obj).sort().map(function(key) { return encodeURIComponent(key) + '=' + ( noencode ? softEncode(obj[key]) : encodeURIComponent(obj[key]));