Closed Bug 498433 Opened 11 years ago Closed 11 years ago

DOM can't parse IPv6 literal URLs

Categories

(Core :: Serializers, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
Tracking Status
status1.9.1 --- .3-fixed

People

(Reporter: lorenzo, Assigned: Biesinger)

References

()

Details

(Keywords: verified1.9.1)

Attachments

(2 files)

If a page contains an IPv6 literal URL such as http://[2001:4860:a003::68]/ , the URL is mangled in the DOM.

To reproduce, create an HTML file containing the following and open it in Firefox:

<html>
<body>
<a href="http://[2001:4860:a003::68]/">Test</a>
</body>
</html>

Note how the link is parsed correctly (and if you have IPv6 connectivity, works). Now select the test, right-click, and "view selection source". Note how the link has become:

<a href="http://%5B2001:4860:a003::68%5D/">Test</a>
Attached patch patchSplinter Review
As best as I can tell, the escaping code here is only for non-ASCII characters, so adding ASCII characters to the whitelist should be safe. compare bug 74137 which added this code.
Attachment #383323 - Flags: superreview?(bzbarsky)
Attachment #383323 - Flags: review?(bzbarsky)
Status: NEW → ASSIGNED
nominating for wanted, as this leads to an incorrect innerHTML of nodes containing links with IPv6 literals
Flags: wanted1.9.1.x?
OS: Linux → All
Hardware: x86 → All
Version: 1.9.1 Branch → Trunk
Attachment #383323 - Flags: superreview?(bzbarsky)
Attachment #383323 - Flags: superreview+
Attachment #383323 - Flags: review?(bzbarsky)
Attachment #383323 - Flags: review+
Comment on attachment 383323 [details] [diff] [review]
patch

I suppose this is ok, but it's not clear why we're doing escaping using nsITextToSubURI here in the first place... can you file a bug on making this sane (e.g. just using NS_Escape with the right flags)?
nsITextToSubURI also does charset conversion before escaping, right? Are you saying that this code should just always use UTF-8?
http://hg.mozilla.org/mozilla-central/rev/719dec02c3a5
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Comment on attachment 383323 [details] [diff] [review]
patch

This is a fairly safe patch to correctly serialize IPv6 address literals, in particular this fixes saving webpages that contain IPv6 links, and also produces correct .innerHTML for such links.
> Are you saying that this code should just always use UTF-8?

Possibly, yes.  At least something to seriously consider.
filed Bug 498636 to simplify that code
Comment on attachment 383323 [details] [diff] [review]
patch

removing dead flag; please generate a new mozilla-1.9.1 patch and request approval on that.
Attachment #383323 - Flags: approval1.9.1?
Attached patch 1.9.1 patchSplinter Review
This is a fairly safe patch to correctly serialize IPv6 address literals, in
particular this fixes saving webpages that contain IPv6 links, and also
produces correct .innerHTML for such links. It's been on trunk for ~6 weeks with no filed regressions. Unit test is included, and there already are tests for this feature in general.
Attachment #391042 - Flags: approval1.9.1.2?
Attachment #391042 - Flags: approval1.9.1.2? → approval1.9.1.3?
Comment on attachment 391042 [details] [diff] [review]
1.9.1 patch

Not for 1.9.1.2.
Comment on attachment 391042 [details] [diff] [review]
1.9.1 patch

Approved for 1.9.1.3. a=ss
Attachment #391042 - Flags: approval1.9.1.3? → approval1.9.1.3+
Verified fixed in 1.9.1 with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3pre) Gecko/20090817 Shiretoko/3.5.3pre (.NET CLR 3.5.30729).
Keywords: verified1.9.1
Flags: wanted1.9.1.x?
You need to log in before you can comment on or make changes to this bug.