Skip to content

Commit

Permalink
Fix double encoding of already encoded character
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelreppi committed May 12, 2023
1 parent f806d0d commit 59e7165
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cjs/html/anchor-element.js
Expand Up @@ -15,10 +15,10 @@ class HTMLAnchorElement extends HTMLElement {
}

/* c8 ignore start */ // copy paste from img.src, already covered
get href() { return encodeURI(stringAttribute.get(this, 'href')); }
get href() { return encodeURI(decodeURI(stringAttribute.get(this, 'href'))); }
set href(value) { stringAttribute.set(this, 'href', decodeURI(value)); }

get download() { return encodeURI(stringAttribute.get(this, 'download')); }
get download() { return encodeURI(decodeURI(stringAttribute.get(this, 'download'))); }
set download(value) { stringAttribute.set(this, 'download', decodeURI(value)); }

get target() { return stringAttribute.get(this, 'target'); }
Expand Down
4 changes: 2 additions & 2 deletions esm/html/anchor-element.js
Expand Up @@ -14,10 +14,10 @@ class HTMLAnchorElement extends HTMLElement {
}

/* c8 ignore start */ // copy paste from img.src, already covered
get href() { return encodeURI(stringAttribute.get(this, 'href')); }
get href() { return encodeURI(decodeURI(stringAttribute.get(this, 'href'))); }
set href(value) { stringAttribute.set(this, 'href', decodeURI(value)); }

get download() { return encodeURI(stringAttribute.get(this, 'download')); }
get download() { return encodeURI(decodeURI(stringAttribute.get(this, 'download'))); }
set download(value) { stringAttribute.set(this, 'download', decodeURI(value)); }

get target() { return stringAttribute.get(this, 'target'); }
Expand Down
3 changes: 2 additions & 1 deletion test/html/anchor-element.js
Expand Up @@ -11,4 +11,5 @@ a.setAttribute('href', 'https://google.com/?q=1&page=2&test="');
assert(a.toString(), '<a href="https://google.com/?q=1&page=2&test=&quot;">click me</a>');
a.setAttribute('href', 'https://google.com/?q=asd&lol=<2>"');
assert(a.href, 'https://google.com/?q=asd&lol=%3C2%3E%22');

a.setAttribute('href', 'https://google.com/path%20to%20some%20file.pdf');
assert(a.href, 'https://google.com/path%20to%20some%20file.pdf');
4 changes: 2 additions & 2 deletions worker.js
Expand Up @@ -11043,10 +11043,10 @@ class HTMLAnchorElement extends HTMLElement {
}

/* c8 ignore start */ // copy paste from img.src, already covered
get href() { return encodeURI(stringAttribute.get(this, 'href')); }
get href() { return encodeURI(decodeURI(stringAttribute.get(this, 'href'))); }
set href(value) { stringAttribute.set(this, 'href', decodeURI(value)); }

get download() { return encodeURI(stringAttribute.get(this, 'download')); }
get download() { return encodeURI(decodeURI(stringAttribute.get(this, 'download'))); }
set download(value) { stringAttribute.set(this, 'download', decodeURI(value)); }

get target() { return stringAttribute.get(this, 'target'); }
Expand Down

0 comments on commit 59e7165

Please sign in to comment.