Bug 259080

Summary: URL pathname and search setter incorrectly strips trailing spaces
Product: WebKit Reporter: Luca Casonato <hello>
Component: PlatformAssignee: Anne van Kesteren <annevk>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, annevk, hello, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   

Description Luca Casonato 2023-07-10 15:43:22 PDT
Test case:

```
const url = new URL('http://example.com/');
url.pathname = '/ ';
url.search = '? ';
url.hash = '# ';
console.log(url.href);
```

Implementations:

```
// whatwg-url@13.0.0
"http://example.com/%20?%20#%20" ✅

// Chrome 117.0.5881.0
"http://example.com/%20?%20#%20" ✅

// Firefox 114.0.2
"http://example.com/%20?%20#%20" ✅

// Safari TP 171
"http://example.com/?#%20" ❌

// Deno 1.35.0
"http://example.com/?%20#%20" ❌

// node@20.4.0
"http://example.com/%20?%20#%20" ✅
```

New tests in https://github.com/web-platform-tests/wpt/pull/40959
Comment 1 Anne van Kesteren 2023-07-15 11:18:30 PDT
One somewhat tricky aspect here is that our internal URL manipulation APIs are not very aligned with the public API, which make me worry we miss certain aspects, in particular around trimming an opaque path when query and fragment become null. I will attempt some refactoring to get them closer together, starting with bug 259245. Feel free to take this however. No promises. :-)
Comment 2 Radar WebKit Bug Importer 2023-07-17 15:44:16 PDT
<rdar://problem/112433299>
Comment 3 Anne van Kesteren 2023-07-23 01:52:58 PDT
Pull request: https://github.com/WebKit/WebKit/pull/16020
Comment 4 EWS 2023-07-24 10:09:25 PDT
Committed 266252@main (cc626f31c374): <https://commits.webkit.org/266252@main>

Reviewed commits have been landed. Closing PR #16020 and removing active labels.
Comment 5 Anne van Kesteren 2023-07-26 09:23:29 PDT
*** Bug 250004 has been marked as a duplicate of this bug. ***