Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPv4 variant to Host and remove custom Ipv6 address type #135

Merged
merged 1 commit into from Nov 15, 2015
Merged

Add IPv4 variant to Host and remove custom Ipv6 address type #135

merged 1 commit into from Nov 15, 2015

Conversation

pyfisch
Copy link
Contributor

@pyfisch pyfisch commented Nov 14, 2015

The Whatwg URL Standard was changed to describe Ipv4 address
parsing. Before this change there was no difference made
between domains and Ipv4 addresses. This change also removes
the custom Ipv6 type and uses the types provided by std for
ip addresses.

https://url.spec.whatwg.org/#syntax-host-ipv4

Note heap_size feature is broken because the HeapSizeOf trait is not yet implemented for the ip addresses.

Review on Reviewable

@pyfisch
Copy link
Contributor Author

pyfisch commented Nov 14, 2015

https://github.com/pyfisch/heapsize/tree/4bdd4e2524e506d9dd23115dff6a9a2249fe6cc4 implements HeapSizeOf for ip addresses.

@pyfisch
Copy link
Contributor Author

pyfisch commented Nov 14, 2015

By the way this solves #116

@untitaker
Copy link
Contributor

@pyfisch I think you should file a PR against heapsize regarding that commit.

bors-servo pushed a commit to servo/heapsize that referenced this pull request Nov 15, 2015
Add Ipv4Addr and Ipv6Addr for use in rust-url

Needed for servo/rust-url#135.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/heapsize/16)
<!-- Reviewable:end -->
bors-servo pushed a commit to servo/heapsize that referenced this pull request Nov 15, 2015
Add Ipv4Addr and Ipv6Addr for use in rust-url

Needed for servo/rust-url#135.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/heapsize/16)
<!-- Reviewable:end -->
@Manishearth
Copy link
Member

Blocked on servo/heapsize#17 getting r+ since crates and the repo weren't in sync.

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 15, 2015

Please bump the heapsize dep to 0.1.3.

@pyfisch
Copy link
Contributor Author

pyfisch commented Nov 15, 2015

done

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 15, 2015

And squash the commits, please

The Whatwg URL Standard was changed to describe Ipv4 address
parsing. Before this change there was no difference made
between domains and Ipv4 addresses. This change also removes
the custom Ipv6 type and uses the types provided by std for
ip addresses.

This is a breaking change. Version bumped to 0.3.0
@pyfisch
Copy link
Contributor Author

pyfisch commented Nov 15, 2015

done

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 15, 2015

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit ecc7bb7 has been approved by Ms2ger

@bors-servo
Copy link
Contributor

⌛ Testing commit ecc7bb7 with merge f71d0f4...

bors-servo pushed a commit that referenced this pull request Nov 15, 2015
Add IPv4 variant to Host and remove custom Ipv6 address type

The Whatwg URL Standard was changed to describe Ipv4 address
parsing. Before this change there was no difference made
between domains and Ipv4 addresses. This change also removes
the custom Ipv6 type and uses the types provided by std for
ip addresses.

https://url.spec.whatwg.org/#syntax-host-ipv4

Note `heap_size` feature is broken because the HeapSizeOf trait is not yet implemented for the ip addresses.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/135)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - travis

@bors-servo bors-servo merged commit ecc7bb7 into servo:master Nov 15, 2015
@pyfisch pyfisch deleted the ipv4addr branch November 15, 2015 20:33
@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 16, 2015

Thanks!

'\0', '\t', '\n', '\r', ' ', '#', '%', '/', ':', '?', '@', '[', '\\', ']'
][..]).is_some() {
Err(ParseError::InvalidDomainCharacter)
if let Ok(addr) = input.parse() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pyfisch @Ms2ger have you verified that Ipv4Addr::parse and Ipv6::parse match https://url.spec.whatwg.org/#host-parsing in every edge case? For example: leading zeros, hex/octal components in v4, …

@SimonSapin
Copy link
Member

I’ve reverted this change. It looks like there was a misunderstanding in the review, sorry. At least the IPv4 parsing of the standard library differs from https://url.spec.whatwg.org/#concept-ipv4-parser . (Note that the "parsing" and "serialization" sections of the spec are more relevant to implementation than the "syntax" sections, which only give a high level overview as opposed to exact algorithms.)

I don’t know if the current parsing or serialization behavior of std for IPv6 happens to match the current spec, but I don’t think we should rely on it staying that way. (I don’t know if it should. Web compatibility with all its weirdness is an overriding concern for browsers, but not as much for a programming language standard library.)

@pyfisch, could you please open a new PR? But keep the existing fmt and parse methods for IPv6, and write IPv4 parsing per https://url.spec.whatwg.org/#concept-ipv4-parser . Or let us know if you’d rather someone else does this work.

@SimonSapin
Copy link
Member

(Edge cases to look for in IPv4 include: leading zeroes, hexadecimal or octal components, less than 4 components.)

@pyfisch
Copy link
Contributor Author

pyfisch commented Nov 18, 2015

I will create a new pull request which will use custom parse methods as they are described in the urlspec. The canonical formatting is unambiguous so I will try to use the methods provided by std but add many tests for edge cases.

@SimonSapin
Copy link
Member

Sounds great, thanks! And yes, serialisation has fewer edge cases than parsing.

@SimonSapin
Copy link
Member

Please also add "Fixes #116" in the new PR or commit message. Thanks!

SimonSapin added a commit that referenced this pull request Nov 19, 2015
… to work around rust-lang/crates.io#76

0.3.0 was published and then yanked:
#135 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants