http: smarter handling of decodeURIComponent calls.
This commit is contained in:
parent
a915545a1a
commit
6a7c5eac8d
@ -251,9 +251,16 @@ function parsePairs(str) {
|
||||
}
|
||||
|
||||
function unescape(str) {
|
||||
str = decodeURIComponent(str);
|
||||
str = str.replace(/\+/g, ' ');
|
||||
str = str.replace(/\0/g, '');
|
||||
try {
|
||||
str = decodeURIComponent(str);
|
||||
str = str.replace(/\+/g, ' ');
|
||||
} catch (e) {
|
||||
throw new Error('Malformed URI.');
|
||||
}
|
||||
|
||||
if (str.indexOf('\0') !== -1)
|
||||
throw new Error('Malformed URI.');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
@ -1654,8 +1654,12 @@ function parsePairs(str, limit) {
|
||||
}
|
||||
|
||||
function unescape(str) {
|
||||
str = decodeURIComponent(str);
|
||||
str = str.replace(/\+/g, ' ');
|
||||
try {
|
||||
str = decodeURIComponent(str);
|
||||
str = str.replace(/\+/g, ' ');
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
str = str.replace(/\0/g, '');
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -923,10 +923,13 @@ Config.prototype.parseForm = function parseForm(query, map) {
|
||||
|
||||
function unescape(str) {
|
||||
try {
|
||||
str = decodeURIComponent(str).replace(/\+/g, ' ');
|
||||
} finally {
|
||||
return str.replace(/\0/g, '');
|
||||
str = decodeURIComponent(str);
|
||||
str = str.replace(/\+/g, ' ');
|
||||
} catch (e) {
|
||||
;
|
||||
}
|
||||
str = str.replace(/\0/g, '');
|
||||
return str;
|
||||
}
|
||||
|
||||
function isAlpha(str) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user