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) {
|
function unescape(str) {
|
||||||
str = decodeURIComponent(str);
|
try {
|
||||||
str = str.replace(/\+/g, ' ');
|
str = decodeURIComponent(str);
|
||||||
str = str.replace(/\0/g, '');
|
str = str.replace(/\+/g, ' ');
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('Malformed URI.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str.indexOf('\0') !== -1)
|
||||||
|
throw new Error('Malformed URI.');
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1654,8 +1654,12 @@ function parsePairs(str, limit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function unescape(str) {
|
function unescape(str) {
|
||||||
str = decodeURIComponent(str);
|
try {
|
||||||
str = str.replace(/\+/g, ' ');
|
str = decodeURIComponent(str);
|
||||||
|
str = str.replace(/\+/g, ' ');
|
||||||
|
} catch (e) {
|
||||||
|
;
|
||||||
|
}
|
||||||
str = str.replace(/\0/g, '');
|
str = str.replace(/\0/g, '');
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -923,10 +923,13 @@ Config.prototype.parseForm = function parseForm(query, map) {
|
|||||||
|
|
||||||
function unescape(str) {
|
function unescape(str) {
|
||||||
try {
|
try {
|
||||||
str = decodeURIComponent(str).replace(/\+/g, ' ');
|
str = decodeURIComponent(str);
|
||||||
} finally {
|
str = str.replace(/\+/g, ' ');
|
||||||
return str.replace(/\0/g, '');
|
} catch (e) {
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
str = str.replace(/\0/g, '');
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAlpha(str) {
|
function isAlpha(str) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user