FIX: Ensure query string in X-Backurl is encoded (fixes #3563)

This commit is contained in:
Loz Calver 2014-10-16 12:24:10 +01:00
parent 7b89c17349
commit e4ddb4b975

View File

@ -515,7 +515,18 @@ jQuery.noConflict();
// Set 'fake' referer - we call pushState() before making the AJAX request, so we have to
// set our own referer here
if (typeof state.data.__forceReferer !== 'undefined') {
headers['X-Backurl'] = state.data.__forceReferer;
// Ensure query string is properly encoded if present
var url = state.data.__forceReferer;
try {
// Prevent double-encoding by attempting to decode
url = decodeURI(url);
} catch(e) {
// URL not encoded, or was encoded incorrectly, so do nothing
} finally {
// Set our referer header to the encoded URL
headers['X-Backurl'] = encodeURI(url);
}
}
contentEls.addClass('loading');