Skip to content

Commit

Permalink
url: remove unused code from autoEscapeStr
Browse files Browse the repository at this point in the history
PR-URL: nodejs#15086
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
cyril-lakech authored and BridgeAR committed Sep 3, 2017
1 parent c419adf commit ed084a0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed084a0

Please sign in to comment.