url: remove unused code from autoEscapeStr
PR-URL: https://github.com/nodejs/node/pull/15086 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
c419adff1d
commit
ed084a035c
14
lib/url.js
14
lib/url.js
@ -360,9 +360,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
|
|||||||
// First, make 100% sure that any "autoEscape" chars get
|
// First, make 100% sure that any "autoEscape" chars get
|
||||||
// escaped, even if encodeURIComponent doesn't think they
|
// escaped, even if encodeURIComponent doesn't think they
|
||||||
// need to be.
|
// need to be.
|
||||||
const result = autoEscapeStr(rest);
|
rest = autoEscapeStr(rest);
|
||||||
if (result !== undefined)
|
|
||||||
rest = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var questionIdx = -1;
|
var questionIdx = -1;
|
||||||
@ -443,8 +441,7 @@ function validateHostname(self, rest, hostname) {
|
|||||||
|
|
||||||
// Automatically escape all delimiters and unwise characters from RFC 2396.
|
// Automatically escape all delimiters and unwise characters from RFC 2396.
|
||||||
// Also escape single quotes in case of an XSS attack.
|
// Also escape single quotes in case of an XSS attack.
|
||||||
// Return undefined if the string doesn't need escaping,
|
// Return the escaped string.
|
||||||
// otherwise return the escaped string.
|
|
||||||
function autoEscapeStr(rest) {
|
function autoEscapeStr(rest) {
|
||||||
var escaped = '';
|
var escaped = '';
|
||||||
var lastEscapedPos = 0;
|
var lastEscapedPos = 0;
|
||||||
@ -540,11 +537,12 @@ function autoEscapeStr(rest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lastEscapedPos === 0) // Nothing has been escaped.
|
if (lastEscapedPos === 0) // Nothing has been escaped.
|
||||||
return;
|
return rest;
|
||||||
|
|
||||||
// There are ordinary characters at the end.
|
// There are ordinary characters at the end.
|
||||||
if (lastEscapedPos < rest.length)
|
if (lastEscapedPos < rest.length)
|
||||||
return escaped + rest.slice(lastEscapedPos);
|
escaped += rest.slice(lastEscapedPos);
|
||||||
else // The last character is escaped.
|
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user