Bug 140174 - DOM URL pathname setter double encodes entities
Summary: DOM URL pathname setter double encodes entities
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.10
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-06 21:13 PST by Joshua Peek
Modified: 2020-06-28 05:23 PDT (History)
4 users (show)

See Also:


Attachments
URL pathname test (679 bytes, patch)
2015-01-06 21:13 PST, Joshua Peek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Peek 2015-01-06 21:13:51 PST
Created attachment 244139 [details]
URL pathname test

The URL pathname setter incorrectly re-encodes the target value before setting it as the pathname attribute. The getter always correctly returns the undecoded pathname.

  var url = new URL("http://example.com/")
  url.pathname = "foo%20bar"
  url.pathname // "/foo%2520bar"
  url.href // "http://example.com/foo%2520bar"

This breaks the ability to reset pathname with the value from its getter.

  var url = new URL("http://example.com/foo%20bar")
  url.pathname // "/foo%20bar"
  url.pathname = url.pathname + "/123"
  url.pathname // "/foo%2520bar/123"

I don't think the pathname setter is correctly performing the "Basic URL parse" step in https://url.spec.whatwg.org/#dom-urlutils-pathname
Comment 1 Rob Buis 2020-06-28 05:23:10 PDT
This is fixed these days.