This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 20752 - IPv6 parser doesn't work well
Summary: IPv6 parser doesn't work well
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: URL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+urlspec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-24 06:45 UTC by NARUSE, Yui
Modified: 2013-02-18 09:25 UTC (History)
1 user (show)

See Also:


Attachments

Description NARUSE, Yui 2013-01-24 06:45:52 UTC
Specification: http://url.spec.whatwg.org/#concept-ipv6-parser

> Substep 7.2.2.
Before this, "Increase pointer by one" is needed.

> Substep 12.3. "While neither piece pointer nor swaps is zero, replace piece with the piece at pointer compress pointer + swaps and then decrease piece pointer and swaps by one."

"compress pointer + swaps" must be "compress pointer + swaps - 1".

And fixed "replace piece with the piece at pointer compress pointer + swaps - 1" is read,
"Set piece to the value of the piece at pointer compress pointer + swaps - 1".
But correct action is
"Set piece to the value of the piece at pointer compress pointer + swaps - 1, then set the piece at pointer compress pointer + swaps - 1 to 0".
Comment 1 Anne 2013-01-25 14:47:01 UTC
It does not need to be set to 0 I think, because they're all initially 0. Am I missing something? Made the other changes:

https://github.com/whatwg/url/commit/a0b00b3d75be2624c14c6b9457c6bc0f93e9a39c
Comment 2 NARUSE, Yui 2013-01-25 20:35:05 UTC
(In reply to comment #1)
> It does not need to be set to 0 I think, because they're all initially 0. Am
> I missing something? Made the other changes:
> 
> https://github.com/whatwg/url/commit/a0b00b3d75be2624c14c6b9457c6bc0f93e9a39c

As far as I understand, the process will run as following, and second piece's value stays 1.

----
After Step 5.

"::1"
 | pointer

# 0  1  2  3  4  5  6  7
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
  | piece pointer
compress pointer = null

----
After Step 6.3.

"::1"
   | pointer

# 0  1  2  3  4  5  6  7
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
     | piece pointer
     | compress pointer

----
After Step 7.7. (first run of While loop)

"::1"
    | pointer

# 0  1  2  3  4  5  6  7
[ 0, 1, 0, 0, 0, 0, 0, 0 ]
        | piece pointer
     | compress pointer

----
After Step 12.2.

swaps = piece pointer (2) - compress pointer (1) = 1
"::1"
    | pointer

# 0  1  2  3  4  5  6  7
[ 0, 1, 0, 0, 0, 0, 0, 0 ]
                       | piece pointer
     | compress pointer

----
At Step 12.3. (first run)

swaps = 1
"::1"
    | pointer

# 0  1  2  3  4  5  6  7
[ 0, 1, 0, 0, 0, 0, 0, 0 ]
                       | piece pointer
     | compress pointer

% neither piece pointer nor swaps is zero
YES
% replace piece with the piece at pointer compress pointer + swaps − 1
# 0  1  2  3  4  5  6  7
[ 0, 1, 0, 0, 0, 0, 0, 1 ]
                       | piece pointer
     | compress pointer
% decrease piece pointer and swaps by one
swaps = 0
# 0  1  2  3  4  5  6  7
[ 0, 1, 0, 0, 0, 0, 0, 1 ]
                    | piece pointer
	 | compress pointer
Comment 3 Anne 2013-02-07 16:25:59 UTC
Thanks for the helpful illustration. My intent with "replace" was "swap". So effectively you put the 1 where the 0 is, and the 0 where the 1 is. If I use the word "swap", do you think that's clear enough?

(Sorry for the late reply, I've been moving countries, and overall IPv6 does not make me happy.)
Comment 4 NARUSE, Yui 2013-02-16 20:55:25 UTC
(In reply to comment #3)
> Thanks for the helpful illustration. My intent with "replace" was "swap". So
> effectively you put the 1 where the 0 is, and the 0 where the 1 is. If I use
> the word "swap", do you think that's clear enough?

Yes, "swap" is much clear for me.

On programming context, for example,
Java's and JavaScript's String.replace, only receiver is changed.
On the other hand, x86's bswap and C++'s std::swap means exchange.

> (Sorry for the late reply, I've been moving countries, and overall IPv6 does
> not make me happy.)

I saw your article, I pray you have a good time in Mozilla.
Comment 6 Anne 2013-02-18 09:25:03 UTC
Thank you!