Closed
Bug 1380323
Opened 8 years ago
Closed 8 years ago
Urlencoded anchors in URL don't scroll to content
Categories
(Core :: DOM: Navigation, defect)
Tracking
()
RESOLVED
FIXED
mozilla57
| Tracking | Status | |
|---|---|---|
| firefox57 | --- | fixed |
People
(Reporter: michal, Assigned: alchen)
References
Details
Attachments
(1 file, 2 obsolete files)
|
4.39 KB,
patch
|
alchen
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Steps to reproduce:
Paste the following link in the location bar and open the page:
https://hexdocs.pm/elixir/Kernel.SpecialForms.html#%3C%3C%3E%3E/1
The page contains an <a> element with a href="#%3C%3C%3E%3E/1" attribute.
Actual results:
The page is opened at the top as if there was no anchor.
Expected results:
The page should scroll to the place where the anchor is.
Updated•8 years ago
|
Component: Untriaged → Document Navigation
Product: Firefox → Core
| Assignee | ||
Comment 2•8 years ago
|
||
sure!!(In reply to Hsin-Yi Tsai (55 Regression Engineering support) [:hsinyi] from comment #1)
> Hi Alphan, would you like to give it a try?
Sure !!
Assignee: nobody → alchen
Flags: needinfo?(alchen)
| Assignee | ||
Comment 3•8 years ago
|
||
Update the finding:
If we replace the id from "%3C%3C%3E%3/1" to "<<>>/1", the page would scroll to the right place.
From:
<h3 id="%3C%3C%3E%3E/1-performance-optimizations" class="section-heading">
To:
<h3 id="<<>>/1-performance-optimizations" class="section-heading">
| Assignee | ||
Comment 4•8 years ago
|
||
I have a patch to fix this symptom.
However, we cannot pass the following wpt-test if applying the patch.
http://w3c-test.org/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html
One more thing, edge has the same symptom as well.
| Assignee | ||
Comment 5•8 years ago
|
||
According the algorithm, the behavior of firefox should be correct.
https://www.w3.org/TR/2011/WD-html5-20110113/history.html#the-indicated-part-of-the-document
3. Let decoded fragid be the result of expanding any sequences of percent-encoded octets in fragid that are valid UTF-8 sequences into Unicode characters as defined by UTF-8. If any percent-encoded octets in that string are not valid UTF-8 sequences, then skip this step and the next one.
| Assignee | ||
Comment 6•8 years ago
|
||
(In reply to Alphan Chen [:alchen] from comment #5)
> According the algorithm, the behavior of firefox should be correct.
> https://www.w3.org/TR/2011/WD-html5-20110113/history.html#the-indicated-part-
> of-the-document
>
> 3. Let decoded fragid be the result of expanding any sequences of
> percent-encoded octets in fragid that are valid UTF-8 sequences into Unicode
> characters as defined by UTF-8. If any percent-encoded octets in that string
> are not valid UTF-8 sequences, then skip this step and the next one.
Hi Anne,
need your help for this bug.
Currently, we cannot scroll to the anchor that the website wants.
(https://hexdocs.pm/elixir/Kernel.SpecialForms.html#%3C%3C%3E%3E/1)
The behavior of Firefox is correct by the spec.
However, Chrome and Safari both can scroll to the right anchor.
There are some options that we can do here.
1. Do nothing. Since we are doing right according to the spec, website developer should follow it.
2. Refine the algorithm in the spec. We could try to find the anchor by original string(without unescape one. in this case, "%3C%3C%3E%3/1") first. Then do unescape one. In this option, we also need to refine the wpt test.(http://w3c-test.org/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html)
3. Just add one more trial(find the anchor by original string) if we cannot find the anchor.
(In reply to Alphan Chen [:alchen] from comment #4)
> I have a patch to fix this symptom.
> However, we cannot pass the following wpt-test if applying the patch.
> http://w3c-test.org/html/browsers/browsing-the-web/scroll-to-fragid/scroll-
> frag-percent-encoded.html
>
Edge can pass the test. Chrome/Safari cannot.
We check the Chrome's code. They will try to find the anchor by original string first(in this case, "%3C%3C%3E%3/1"). Then try the document's charset(in this case, "<<>>/1").
Flags: needinfo?(annevk)
Comment 7•8 years ago
|
||
https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-indicated-part-of-the-document is a better reference, though in this case they happen to be similar.
I suspect Edge first tries the decoded variant and then the original string. (Though it seems to do the opposite for :target matching. Or maybe :target matching doesn't decode at all, unclear. I didn't test it deeply.)
I think we should match Chrome/Safari and update the standard and that test. (I'll work on a PR for the standard as a start.)
Flags: needinfo?(annevk)
Comment 8•8 years ago
|
||
Created https://github.com/whatwg/html/pull/2901 with a revised algorithm. Would you be willing to update the tests?
Might be good to expand that test to cover some other scenarios as well. E.g., that <a name=literal> is found before <a id=decoded> and such.
| Assignee | ||
Comment 9•8 years ago
|
||
(In reply to Anne (:annevk) from comment #8)
> Created https://github.com/whatwg/html/pull/2901 with a revised algorithm.
> Would you be willing to update the tests?
>
> Might be good to expand that test to cover some other scenarios as well.
> E.g., that <a name=literal> is found before <a id=decoded> and such.
OK, I will update the tests and create a pull request.
| Assignee | ||
Comment 10•8 years ago
|
||
(In reply to Anne (:annevk) from comment #8)
> Created https://github.com/whatwg/html/pull/2901 with a revised algorithm.
> Would you be willing to update the tests?
>
> Might be good to expand that test to cover some other scenarios as well.
> E.g., that <a name=literal> is found before <a id=decoded> and such.
Here is the pull request.
https://github.com/w3c/web-platform-tests/pull/6887
| Assignee | ||
Comment 11•8 years ago
|
||
Here is the patch according to the revised algorithm.
We can pass the tests with this patch.
https://github.com/w3c/web-platform-tests/pull/6887
Comment 12•8 years ago
|
||
Thanks, sorry for the delay. I think your tests look good. Just waiting for someone to sign off on the HTML Standard change. You should feel free to go ahead with the Firefox change though since this is the way to go.
Updated•8 years ago
|
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
| Assignee | ||
Comment 13•8 years ago
|
||
In this patch, we follow the latest algorithm[1].
The wpt test also needs to be updated[2].
Before pulling the latest wpt test, we expect the test would be failed.
[1] https://github.com/whatwg/html/pull/2901
[2] https://github.com/w3c/web-platform-tests/pull/6887
Attachment #8897364 -
Attachment is obsolete: true
Attachment #8899747 -
Flags: review?(ehsan)
Comment 14•8 years ago
|
||
Comment on attachment 8899747 [details] [diff] [review]
Revise the behavior of scrolling to fragments
Review of attachment 8899747 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/base/nsDocument.cpp
@@ +10011,5 @@
> if (shell) {
> + nsresult rv = NS_ERROR_FAILURE;
> + // We assume that the bytes are in UTF-8, as it says in the spec:
> + // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
> + NS_ConvertUTF8toUTF16 ref(mScrollToRef);
Nit: You only need |ref| inside the if condition, so you could modify the condition itself to check mScrollToRef.IsEmpty() instead and then move the NS_ConvertUTF8toUTF16 to inside the if body to avoid doing that work in the else case.
Attachment #8899747 -
Flags: review?(ehsan) → review+
| Assignee | ||
Comment 15•8 years ago
|
||
Comment on attachment 8899747 [details] [diff] [review]
Revise the behavior of scrolling to fragments
Review of attachment 8899747 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/base/nsDocument.cpp
@@ +10011,5 @@
> if (shell) {
> + nsresult rv = NS_ERROR_FAILURE;
> + // We assume that the bytes are in UTF-8, as it says in the spec:
> + // http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.1
> + NS_ConvertUTF8toUTF16 ref(mScrollToRef);
Actually, we check mScrollToRef.IsEmpty() in line 10006.
The if checking is for "empty string which might be caused by the UTF-8 conversion".
| Assignee | ||
Comment 16•8 years ago
|
||
Try:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=29ffcc3cd2833d590372a567c409320fc1278a7f
Attachment #8899747 -
Attachment is obsolete: true
Attachment #8901705 -
Flags: review+
| Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
Comment 17•8 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/44cc06afd53d
Revise the behavior of scrolling to fragments. r=ehsan
Keywords: checkin-needed
Comment 18•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox57:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in
before you can comment on or make changes to this bug.
Description
•