Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only strip spaces from opaque path when both query and fragment are null #842

Closed
wants to merge 1 commit into from

Conversation

ohno418
Copy link

@ohno418 ohno418 commented Jun 14, 2023

In the current behavior, when url.set_query(None) is called to remove
the query from a opaque path, spaces are stripped even if a fragment
remains.

As the spec 1 says, strip spaces only when both the query and fragment
are null. For example:

let mut url = URL::parse("data:space   ?query#hash");
url.set_query(None);
assert_eq!(url.as_str(), "data:space   #hash")

You can find the related test here:
https://github.com/web-platform-tests/wpt/pull/37556/files#diff-316fd17e018fdca0e399146c072ea3a95a08fe1ccd3f8fe940d73ca2b9d26c9eR57-R63

In the current behavior, when `url.set_query(None)` is called to remove
the query from a opaque path, spaces are stripped even if a fragment
remains.

As the spec [1] says, strip spaces only when both the query and fragment
are null. For example:

```
let mut url = URL::parse("data:space   ?query#hash");
url.set_query(None);
assert_eq!(url.as_str(), "data:space   #hash")
```

[1]: https://url.spec.whatwg.org/#potentially-strip-trailing-spaces-from-an-opaque-path
Comment on lines +1558 to 1559
self.restore_already_parsed_fragment(fragment);
self.strip_trailing_spaces_from_opaque_path();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stripping spaces should only happen when the fragment is null, so the fragment should be restored first.

@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (0e25146) 82.44% compared to head (6ee00ad) 82.44%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #842   +/-   ##
=======================================
  Coverage   82.44%   82.44%           
=======================================
  Files          20       20           
  Lines        3343     3349    +6     
=======================================
+ Hits         2756     2761    +5     
- Misses        587      588    +1     
Impacted Files Coverage Δ
url/src/lib.rs 76.00% <100.00%> (-0.07%) ⬇️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@valenting
Copy link
Collaborator

I think this was fixed in #879

@valenting valenting closed this Nov 10, 2023
@ohno418 ohno418 deleted the fix-space-stripping branch November 10, 2023 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants