diff options
author | Cyril Lakech <cyril.lakech@axa.fr> | 2017-08-30 10:53:52 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-09-03 17:26:18 -0300 |
commit | ed084a035c1f657284f3eee7f7a583a42e8b35f1 (patch) | |
tree | 2265073743a78fb06a5f64cfd1ea0c83b18caad3 /lib/url.js | |
parent | c419adff1d2cb8a71add8dc0027607715ae731ea (diff) | |
download | android-node-v8-ed084a035c1f657284f3eee7f7a583a42e8b35f1.tar.gz android-node-v8-ed084a035c1f657284f3eee7f7a583a42e8b35f1.tar.bz2 android-node-v8-ed084a035c1f657284f3eee7f7a583a42e8b35f1.zip |
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>
Diffstat (limited to 'lib/url.js')
-rw-r--r-- | lib/url.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/url.js b/lib/url.js index f48ad08512..887f5c29ce 100644 --- a/lib/url.js +++ b/lib/url.js @@ -360,9 +360,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { // First, make 100% sure that any "autoEscape" chars get // escaped, even if encodeURIComponent doesn't think they // need to be. - const result = autoEscapeStr(rest); - if (result !== undefined) - rest = result; + rest = autoEscapeStr(rest); } var questionIdx = -1; @@ -443,8 +441,7 @@ function validateHostname(self, rest, hostname) { // Automatically escape all delimiters and unwise characters from RFC 2396. // Also escape single quotes in case of an XSS attack. -// Return undefined if the string doesn't need escaping, -// otherwise return the escaped string. +// Return the escaped string. function autoEscapeStr(rest) { var escaped = ''; var lastEscapedPos = 0; @@ -540,12 +537,13 @@ function autoEscapeStr(rest) { } } if (lastEscapedPos === 0) // Nothing has been escaped. - return; + return rest; + // There are ordinary characters at the end. if (lastEscapedPos < rest.length) - return escaped + rest.slice(lastEscapedPos); - else // The last character is escaped. - return escaped; + escaped += rest.slice(lastEscapedPos); + + return escaped; } // format a parsed object into a url string |