Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(urlUtils): make IPv6 URL's hostname wrapped in square brackets in IE/Edge #16715

Merged
merged 1 commit into from Oct 18, 2018

Conversation

mgol
Copy link
Member

@mgol mgol commented Oct 11, 2018

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

A bug fix.

What is the current behavior? (You can also link to an open issue here)

In IE 9-11 and Edge 16-17 (not in 18 Preview) $location.host() incorrectly returns hostnames of IPv6 addresses without wrapping in square brackets.

This is caused by and IE/Edge bug which incorrectly don't wrap IPv6 addresses' hostnames in square brackets when parsed out of an anchor element which is used by $location for the purpose of URL parsing.

Issue: #16692

What is the new behavior (if this is a feature change)?

For all supported browsers $location.host() returns an IPv6 address wrapped in square brackets.

Does this PR introduce a breaking change?

No

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Fix/Feature: Docs have been added/updated
  • Fix/Feature: Tests have been added; existing tests pass

Other information:

@mgol mgol added this to the 1.7.x milestone Oct 11, 2018
@mgol mgol self-assigned this Oct 11, 2018
mgol added a commit to mgol/angular.js that referenced this pull request Oct 11, 2018
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes angular#16692
Closes angular#16715
@mgol
Copy link
Member Author

mgol commented Oct 11, 2018

I added a support test to avoid an overhead of additional regex testing per each URL passing through urlResolve.

@@ -72,13 +78,19 @@ function urlResolve(url) {

urlParsingNode.setAttribute('href', href);

var hostname = urlParsingNode.hostname;

if (!ipv6InBrackets && /[\da-e:]+/.test(hostname)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not a-f in the RegExp?
Also, you probably meant /^[...]+$/ (to match the whole hostname, not just a part of it).

Copy link
Member Author

Choose a reason for hiding this comment

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

Off-by-one error! I broke https://google.com parsing. 😱 Fixed.

mgol added a commit to mgol/angular.js that referenced this pull request Oct 11, 2018
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes angular#16692
Closes angular#16715
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

LGTM

src/ng/urlUtils.js Outdated Show resolved Hide resolved
src/ng/urlUtils.js Outdated Show resolved Hide resolved
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes angular#16692
Closes angular#16715
@mgol mgol merged commit b4e409b into angular:master Oct 18, 2018
@mgol mgol deleted the ipv6-ie-edge branch October 18, 2018 09:45
mgol added a commit that referenced this pull request Oct 18, 2018
… IE/Edge

IE 9-11 and Edge 16-17 (fixed in 18 Preview) incorrectly don't wrap IPv6
addresses' hostnames in square brackets when parsed out of an anchor element.

Fixes #16692
Closes #16715
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.

None yet

4 participants