GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — url: remove \t \n \r in url.parse() similar to WHATWG · nodejs/node@5d964cd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • url.js
  • test/parallel
    • test-url-parse-format.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/url.js‎

Copy file name to clipboardExpand all lines: lib/url.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
319319
case CHAR_TAB:
320320
case CHAR_LINE_FEED:
321321
case CHAR_CARRIAGE_RETURN:
322+
// WHATWG URL removes tabs, newlines, and carriage returns. Let's do that too.
323+
rest = rest.slice(0, i) + rest.slice(i + 1);
324+
i -= 1;
325+
break;
322326
case CHAR_SPACE:
323327
case CHAR_DOUBLE_QUOTE:
324328
case CHAR_PERCENT:
Collapse file

‎test/parallel/test-url-parse-format.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-url-parse-format.js
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -853,16 +853,16 @@ const parseTests = {
853853
'http://a\r" \t\n<\'b:b@c\r\nd/e?f': {
854854
protocol: 'http:',
855855
slashes: true,
856-
auth: 'a\r" \t\n<\'b:b',
857-
host: 'c',
856+
auth: 'a" <\'b:b',
857+
host: 'cd',
858858
port: null,
859-
hostname: 'c',
859+
hostname: 'cd',
860860
hash: null,
861861
search: '?f',
862862
query: 'f',
863-
pathname: '%0D%0Ad/e',
864-
path: '%0D%0Ad/e?f',
865-
href: 'http://a%0D%22%20%09%0A%3C\'b:b@c/%0D%0Ad/e?f'
863+
pathname: '/e',
864+
path: '/e?f',
865+
href: 'http://a%22%20%3C\'b:b@cd/e?f'
866866
},
867867

868868
// Git urls used by npm
@@ -1023,7 +1023,7 @@ for (const u in parseTests) {
10231023
assert.deepStrictEqual(
10241024
actual,
10251025
expected,
1026-
`expected ${inspect(expected)}, got ${inspect(actual)}`
1026+
`parsing ${u} and expected ${inspect(expected)} but got ${inspect(actual)}`
10271027
);
10281028
assert.deepStrictEqual(
10291029
spaced,

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.