Closed Bug 1874118 Opened 2 years ago Closed 1 year ago

Do not drop trailing spaces from non-trailing opaque paths data: URL

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

RESOLVED FIXED
129 Branch
Tracking Status
firefox129 --- fixed

People

(Reporter: valentin, Assigned: sekim)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

No description provided.

<a>: Setting <data:space ?query#fragment>.search = '' Do not drop trailing spaces from non-trailing opaque paths
FAIL message: assert_equals: expected "data:space #fragment" but got "data:space#fragment"

Assignee: nobody → sekim
{
            "comment": "Do not drop trailing spaces from non-trailing opaque",
            "href": "data:space ?query#fragment",
            "new_value": "",
            "expected": {
                "href": "data:space #fragment",
                "search": ""
            }
}

Adding this under search in setters_tests.json (rust-url) somehow passes, could you elaborate more on the test it is failing? Thanks

Flags: needinfo?(valentin.gosu)

rust-url isn't being used for data URLs.
We use simpleURI for that https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataHandler.cpp
And I think the weird thing was that it only happens for <a> elements, not for the URL object.
So this works:

u = new URL("data:space ?query#fragment")
u.search = "" 
u.href // "data:space #fragment" 

but this doesn't:

x = document.createElement("a");
x.href = "data:space ?query#fragment";
x.search = "";
x.href // "data:space#fragment"

It's unclear why these two behave differently.

Flags: needinfo?(valentin.gosu)

Maybe because we call SetHrefAttribute after changing the query - and that somehow ends up stripping the space?

The difference is

u = new URL("data:space ?q")
u.href // "data:space ?q"

u = new URL("data:space #q")
u.href // "data:space#q"

The second one is wrong. I think nsSimpleURI is to blame.

u = Services.io.newURI("data:space #q"); (in the browser console, Ctrl-Shift-J)
u.spec

has the same issue.

Pushed by eguloien@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5573d35897e6 Fix handling of trailing characters in opaque paths in URL r=valentin,necko-reviewers
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: