Closed Bug 867407 Opened 11 years ago Closed 9 years ago

Navigating to local file through a (local) symlink strips query (?a=b) and fragment identifier (#anchor) from the link

Categories

(Core :: Networking: File, defect)

15 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed
b2g-v2.5 --- fixed

People

(Reporter: megan.smith, Assigned: billm)

References

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31

Steps to reproduce:

1) Create a local html file that is a symlink to a source local html file.
2) In the URL bar, type file://<path to symlink>#<an anchor in the source file>
3) Hit enter


Actual results:

Firefox navigates to the beginning of the source file, minus the anchor link.


Expected results:

Firefox navigates to the correct anchor in the source file.
Confirmed with 2013-05-06-03-09-25-mozilla-central-firefox-23.0a1.ru.linux-x86_64.
Status: UNCONFIRMED → NEW
Depends on: CVE-2012-1945
Ever confirmed: true
Summary: Navigating to local symlinked file with an anchor link strips anchor link → Navigating to local file through a (local) symlink strips anchor from the link
Since Fx 15: https://bugzilla.mozilla.org/show_bug.cgi?id=670514#c63
Version: 16 Branch → 15 Branch
(In reply to [:Aleksej] from comment #2)
> Since Fx 15: https://bugzilla.mozilla.org/show_bug.cgi?id=670514#c63

-g 2012-05-03-03-05-12-mozilla-central-firefox-15.0a1.en-US.linux-x86_64 807403a04a6a
-b 2012-05-04-12-29-39-mozilla-central-firefox-15.0a1.en-US.linux-x86_64 9ebf3dc839c5
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=807403a04a6a&tochange=9ebf3dc839c5

-b 2015-03-30-03-02-03-mozilla-central-firefox-39.0a1.ru.linux-x86_64
Component: Untriaged → Networking: File
No longer depends on: CVE-2012-1945
Keywords: regression
Product: Firefox → Core
See Also: → 1051117
See Also: → 1148173
Summary: Navigating to local file through a (local) symlink strips anchor from the link → Navigating to local file through a (local) symlink strips fragment identifier (anchor) from the link
This still reproduces in Firefox Nightly 39, FWIW. (I just tried it with a file in /tmp and a symlink to that file.)
See Also: 1148173
As noted in bug 1051117 comment 17, the symlink translation-to-actual-file happens in  nsFileChannel::nsFileChannel() -- that's where we lose the fragment identifier (and anything else after the filename).

MXR link: http://mxr.mozilla.org/mozilla-central/source/netwerk/protocol/file/nsFileChannel.cpp?rev=ac4464790ec4&mark=260-269#260

There, 'uri' (and hence 'fileURL') has the fragment identifier, but 'targetURI' (produced by the long 'if' statement) does not -- and that's the problem.
Summary: Navigating to local file through a (local) symlink strips fragment identifier (anchor) from the link → Navigating to local file through a (local) symlink strips query (?a=b) and fragment identifier (#anchor) from the link
Assignee: nobody → netzen
I won't have time for this in the near future so unassigned myself for now.
Attached patch patchSplinter Review
This fixes the problem I was experiencing with a test not running locally.
Assignee: netzen → wmccloskey
Status: NEW → ASSIGNED
Attachment #8634798 - Flags: review?(sworkman)
Comment on attachment 8634798 [details] [diff] [review]
patch

Review of attachment 8634798 [details] [diff] [review]:
-----------------------------------------------------------------

Looks sane to me. Can we get a try run for this before landing please? Pending that and the naming nit, r=me.

::: netwerk/protocol/file/nsFileChannel.cpp
@@ +276,5 @@
> +    nsCOMPtr<nsIURL> origURL = do_QueryInterface(uri);
> +    nsCOMPtr<nsIURL> targetURL = do_QueryInterface(targetURI);
> +    nsAutoCString search;
> +    if (origURL && targetURL && NS_SUCCEEDED(origURL->GetQuery(search))) {
> +      targetURL->SetQuery(search);

s/search/queryString/
Attachment #8634798 - Flags: review?(sworkman) → review+
https://hg.mozilla.org/mozilla-central/rev/16ab2ae184c0
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: