Bug 140174

Summary: DOM URL pathname setter double encodes entities
Product: WebKit Reporter: Joshua Peek <josh>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: annevk, ap, aroben, rbuis
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.10   
Attachments:
Description Flags
URL pathname test none

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.