Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Fix Uri.Host for IPv6 Link-local address #29769

Merged
merged 9 commits into from
May 19, 2018
Merged

Fix Uri.Host for IPv6 Link-local address #29769

merged 9 commits into from
May 19, 2018

Conversation

MarcoRossignoli
Copy link
Member

@MarcoRossignoli MarcoRossignoli commented May 17, 2018

contributes to #28863

this PR address the second part of issue:

  1. Uri.Host LLA (Link-local address) IPv6 address doesn't contain %number part.
  • Currently it returns [fe80::e077:c9a3:eeba:b8e9], it should return [fe80::e077:c9a3:eeba:b8e9%18].
  • Note: Uri.IdnHost correctly contains the %number part.

cc: @rmkerr @Caesar1995 @davidsh

@davidsh
Copy link
Contributor

davidsh commented May 17, 2018

Thanks for the PR.

contributes to #28863

In the future, it would be better if the commit description were clearer about what this does exactly. That issue has multiple parts to it. So, perhaps this particular PR is addressing the enclosing brackets ('[', ']') for IPv6 link-local addresses or the scope-id w/ percent character? Either way, it would be good to add more details for commits and the PR description.

[InlineData("FE80::e077:c9a3:eeba:b8e9", "%eth10", true)]
[InlineData("fe81::e077:c9a3:eeba:b8e9", "%18", false)]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void UriIPv6Host_LinkLocalAddress(string address, string zoneIndex, bool isValidLinkLocalAddress)
Copy link
Contributor

Choose a reason for hiding this comment

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

The test name should be 3 parts, so it should probably be named like this: "Host_IPv6LinkLocalAddress_HasScopeId"

  • First part describes the method or property under test. In this case, the test is validating the .Host property.
  • Second part describes the inputs to the test.
  • Third part describes the expected result.

Copy link
Contributor

@davidsh davidsh May 17, 2018

Choose a reason for hiding this comment

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

Also, you should separate out the valid and invalid cases into separate tests. The invalid one could be named, "Host_NonIPv6LinkLocalAddress_NoScopeId"

[InlineData("fE80::e077:c9a3:eeba:b8e9", "%18")]
[InlineData("FE80::e077:c9a3:eeba:b8e9", "%18")]
[InlineData("FE80::e077:c9a3:eeba:b8e9", "%eth10")]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
Copy link
Member Author

Choose a reason for hiding this comment

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

@davidsh do you consider porting on netfx?

Copy link
Contributor

Choose a reason for hiding this comment

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

I will mark it as "consider". But those things have longer lead times for review and it might not qualify due to strict app-compat guidelines.

@MarcoRossignoli
Copy link
Member Author

Either way, it would be good to add more details for commits and the PR description.

you're right sorry, updated.

[InlineData("Fe80::e077:c9a3:eeba:b8e9", "%18")]
[InlineData("fE80::e077:c9a3:eeba:b8e9", "%18")]
[InlineData("FE80::e077:c9a3:eeba:b8e9", "%18")]
[InlineData("FE80::e077:c9a3:eeba:b8e9", "%eth10")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be nice to add some additional test cases here for more interesting scope IDs. What happens if we include an empty scope? Or scopes containing unusual characters?

Copy link
Member Author

@MarcoRossignoli MarcoRossignoli May 17, 2018

Choose a reason for hiding this comment

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

What happens if we include an empty scope?

This test pass.
In this case what we want?Do we need to throw invalid address exception?Can we "parse" LLA without zone index?
IMHO if an address is LLA(start with fe80) we should throw exception, if i'm not mistaken LLA MUST have a zone index, what do you think?

Copy link
Member Author

@MarcoRossignoli MarcoRossignoli May 17, 2018

Choose a reason for hiding this comment

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

Or scopes containing unusual characters?

With special chars like [InlineData("FE80::e077:c9a3:eeba:b8e9", "\u30AF\u20E7")] we get exception Invalid URI: The hostname could not be parsed. before reaching Ipv6 parser.

From rfc specification:

A <zone_id> SHOULD contain only ASCII characters classified as
"unreserved" for use in URIs [RFC3986].  This excludes characters
such as "]" or even "%" that would complicate parsing.  However, the
syntax described below does allow such characters to be percent-
encoded, for compatibility with existing devices that use them.

here behaviour seems correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Throwing an exception with special characters seems like the right behavior, especially considering we do the same thing before the change.

On the other hand, throwing a new exception for an empty scope is risky. I think we could justify it if creating an LLA without a zone id really isn't a meaningful operation, but otherwise it's probably better to be more accepting of potentially valid addresses. As far as I can tell, the spec implies that the zone id should be non-null, but never says it explicitly. From RFC 4007 11.2:

An implementation MAY support other kinds of non-null strings as <zone_id>.

So without the spec explicitly forbidding null zone ids, I'd be inclined to stick with the behavior you have in the PR now. @davidsh, any thoughts on this?

Copy link
Contributor

@davidsh davidsh May 18, 2018

Choose a reason for hiding this comment

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

@davidsh, any thoughts on this?

This PR should be focussed on one thing. And changing behavior for something else shouldn't be part of that.

So, no, don't start throwing a new exception for empty scope-id.

Copy link
Member Author

Choose a reason for hiding this comment

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

@rmkerr @davidsh i added empty scope-id test case, would you like also a test with "special characters" for zone id(throwing exception assert)?

Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to have that behavior pinned, so yes! That should be easy to implement using Assert.Throws. Also, could you try the case where we have the zone ID "%" with no scope ID following. It's another unusual case, but I would hope we get the same behavior as when we provide a totally empty zone ID.

@MarcoRossignoli
Copy link
Member Author

@dotnet-bot test OSX x64 Debug Build please
@dotnet-bot test Windows x64 Debug Build please

@rmkerr
Copy link
Contributor

rmkerr commented May 18, 2018

@MarcoRossignoli The test failures you're seeing in Win10 Nano are a consequence of #29757 and are not related. I'm not sure about the OSX run, but that leg does tend to be fairly unstable.

[InlineData("FE80::e077:c9a3:eeba:b8e9", "%eth10")]
[InlineData("FE80::e077:c9a3:eeba:b8e9", "")]
[InlineData("FE80::e077:c9a3:eeba:b8e9", "%")]
[InlineData("fe80::e077:c9a3:eeba:b8e9", "%\u30AF\u20E7")]
Copy link
Member Author

@MarcoRossignoli MarcoRossignoli May 18, 2018

Choose a reason for hiding this comment

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

@rmkerr actually special characters works well...i forget % escape char in zone-id test data, however this behaviour is conform to rfc SHOULD contain only ASCII is not a MUST.

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds fine to me, if we allowed Unicode characters before we should continue to allow them. Thanks for updating the tests.

Copy link
Contributor

@rmkerr rmkerr left a comment

Choose a reason for hiding this comment

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

Assuming the tests pass in CI this looks good to me.

@davidsh davidsh added this to the 2.2.0 milestone May 19, 2018
@davidsh
Copy link
Contributor

davidsh commented May 19, 2018

@davidsh davidsh merged commit e1ded5a into dotnet:master May 19, 2018
@MarcoRossignoli MarcoRossignoli deleted the ipv6lla branch May 19, 2018 05:26
@stephentoub
Copy link
Member

Were outer loop tests run on this? Many outerloop Windows and Linux runs are failing, and it appears to be due to this, with errors from GetAsync_IPv6LinkLocalAddressUri_Success like "URL using bad/illegal format or missing URL" and "No such device or address"

stephentoub added a commit that referenced this pull request May 21, 2018
stephentoub added a commit to stephentoub/corefx that referenced this pull request May 21, 2018
stephentoub added a commit that referenced this pull request May 21, 2018
davidsh pushed a commit that referenced this pull request May 30, 2018
Contributes to #28863

Replace PR #29769 after revert #29818 for Outerloop CI fail

This PR address the second part of issue:

Uri.Host LLA (Link-local address) IPv6 address doesn't contain %number part.
Currently it returns [fe80::e077:c9a3:eeba:b8e9], it should return [fe80::e077:c9a3:eeba:b8e9%18].

Note: Uri.IdnHost correctly contains the %number part.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Contributes to dotnet/corefx#28863

This PR address the second part of issue:

Uri.Host LLA (Link-local address) IPv6 address doesn't contain %number part.
Currently it returns [fe80::e077:c9a3:eeba:b8e9], it should return [fe80::e077:c9a3:eeba:b8e9%18].

Note: Uri.IdnHost correctly contains the %number part.

Commit migrated from dotnet/corefx@e1ded5a
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Contributes to dotnet/corefx#28863

Replace PR dotnet/corefx#29769 after revert dotnet/corefx#29818 for Outerloop CI fail

This PR address the second part of issue:

Uri.Host LLA (Link-local address) IPv6 address doesn't contain %number part.
Currently it returns [fe80::e077:c9a3:eeba:b8e9], it should return [fe80::e077:c9a3:eeba:b8e9%18].

Note: Uri.IdnHost correctly contains the %number part.


Commit migrated from dotnet/corefx@f7a8cf1
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants