From ffb2ef4ff3023a9ce3b0778f7d1506c08de8d9ee Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Wed, 12 Apr 2017 20:43:22 +0200 Subject: [PATCH] url: remove javascript URL special case PR-URL: https://github.com/nodejs/node/pull/12507 Fixes: https://github.com/nodejs/node/issues/11485 Reviewed-By: James M Snell --- lib/internal/url.js | 2 -- test/fixtures/url-setter-tests.js | 16 ++++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 9a70838c30d4a1..74d8de63d90310 100644 --- a/lib/internal/url.js +++ b/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; diff --git a/test/fixtures/url-setter-tests.js b/test/fixtures/url-setter-tests.js index d0688611a01c0f..4c39cb7311791b 100644 --- a/test/fixtures/url-setter-tests.js +++ b/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" + } + } ] }