Closed Bug 748140 Opened 12 years ago Closed 7 years ago

Backslash converted to forward slash when copying file:// url, even in query string or hash

Categories

(Core :: Networking, defect)

11 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1348876

People

(Reporter: kip.robinson, Unassigned)

References

(Depends on 1 open bug)

Details

(Whiteboard: [necko-backlog])

Attachments

(1 file)

(deleted), text/plain
Details
Attached file test.html (deleted) —
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0
Build ID: 20120312181643

Steps to reproduce:

Note: This may only apply to Windows OS.

1. Open any HTML file from your local system.
2. Open console window and enter Javascript command:
    location.hash = 'tst=' + encodeURIComponent('\\')
3. Copy the URL from the address bar


Actual results:

After step 1, URL is something like:
  file:///C:/temp/test.html
After step 2. After entering Javascript command, URL is shown as:
  file:///C:/temp/test.html#tst=\
After step 3, the clipboard contains:
  file:///C:/temp/test.html#tst=/

Problem: the backslash was changed to a forward slash.


Expected results:

Either:

a. The URL should should have shown with the backslash encoded, as entered in Javascript: "#tst=%5C"
 -or-
b. When copying the URL, backslashes should not be converted to forward slash in query string or in location hash.


I think it is important to note that this happened even though my Javascript correctly escaped the backslash as %5C.

Note: The scenario above only covers location hash, but this also happens in query string. The attached document uses HTML5 history.push to set a query string containing a backslash.
Depends on: url
Status: UNCONFIRMED → NEW
Component: Untriaged → Networking
Ever confirmed: true
Product: Firefox → Core
Whiteboard: [necko-backlog]
Just to note I've found this issue too - \ in the query part (?...\...) of a file: (but not http:) request entered in the address bar incorrectly changes to a /
I'm surprised it's taken so long to address... I hope this comment may prod the matter forward :)
Cheers,
David
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE

I don't think this is a duplicate of bug 1348876. The underlying causes are different:

Bug 1348876: The address bar decodes "%5C" into "", making the shown URL invalid (and pressing enter in the address bar causes "" to be replaced with "/").

This bug: The backslash replacing algorithm in the URL parser seemingly doesn't stop at "#" or "?" when parsing file: URLs.
Example STR: new URL("file:///#\").hash == "#/"

Oops, markdown ate some backslashes. Let's try again:

I don't think this is a duplicate of bug 1348876. The underlying causes are different:

Bug 1348876: The address bar decodes %5C into \\, making the shown URL invalid (and pressing enter in the address bar causes \ to be replaced with /).

This bug: The backslash replacing algorithm in the URL parser seemingly doesn't stop at # or ? when parsing file: URLs.
For example, new URL("file:///#\\").hash returns #/

That \\ should be \. Sorry for the bugmail spam.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: