Browse Source

url: remove javascript URL special case

Fixes: https://github.com/nodejs/node/issues/11485
PR-URL: https://github.com/nodejs/node/pull/12331
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6
Daijiro Wachi 8 years ago
parent
commit
eb0492d51e
  1. 2
      lib/internal/url.js
  2. 16
      test/fixtures/url-setter-tests.js

2
lib/internal/url.js

@ -556,8 +556,6 @@ Object.defineProperties(URL.prototype, {
const ctx = this[context];
// toUSVString is not needed.
hash = `${hash}`;
if (this.protocol === 'javascript:')
return;
if (!hash) {
ctx.fragment = null;
ctx.flags &= ~binding.URL_FLAGS_HAS_FRAGMENT;

16
test/fixtures/url-setter-tests.js

@ -1800,13 +1800,13 @@ module.exports =
"hash": "#%c3%89t%C3%A9"
}
},
// {
// "href": "javascript:alert(1)",
// "new_value": "castle",
// "expected": {
// "href": "javascript:alert(1)#castle",
// "hash": "#castle"
// }
// }
{
"href": "javascript:alert(1)",
"new_value": "castle",
"expected": {
"href": "javascript:alert(1)#castle",
"hash": "#castle"
}
}
]
}

Loading…
Cancel
Save