New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 684201 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Anchor Tag Doesn't Match EncodeURI/DecodURI

Reported by alan....@optimizely.com, Jan 24 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36

Steps to reproduce the problem:
1. create an anchor element `var anchor = document.createElement('a')`
2. set the href of the anchor `anchor.href = 'https://gamma`
3. get the origin of the anchor `anchor.origin === 'https://gamma`

What is the expected behavior?
I expect the return value of anchor.origin to be 'https://gamma.

What went wrong?
The returned string of anchor.origin is 'https://gamma%24', which is less than ideal, except that when I pass the string into decodeURI, decodeURI doesn't decode the '%24' into '.  I kind of expect the return value of an anchor element to align with encodeURI/decodeURI.

I've checked in firefox and the returned value of anchor.origin is what I expected it to be.

Did this work before? N/A 

Chrome version: 55.0.2883.95  Channel: stable
OS Version: OS X 10.11.6
Flash Version: Shockwave Flash 24.0 r0
 
Apparently my dollar sign ($) is getting stripped everywhere in this comment.

There should be a dollar sign appended to all of the urls.
Labels: Needs-Triage-M55
Cc: ranjitkan@chromium.org
Labels: Needs-Feedback
@alan.sun: Thanks for filing the issue, could you please help us with a sample test case (an Html or a jsfiddle example). This will help us to triage the issue better.

Thanks.!
@ranjitkan, here's a jsfiddle: https://jsfiddle.net/2Lnk0qLd/1/

Thanks for the fiddle example, launched the example on chrome version 55.0.2883.95 on MAC 10.12.2 and observed the output as attached in the screenshot in dev console. Same behavior is observed on M24 chrome version 24.0.1300.0. Is this issue you have mentioned about. Request you to please check and confirm 
684201_Screenshot.png
82.9 KB View Download
The screenshot looks correct. The test cases I wrote out in the jsfiddle are, I think, the correct behavior.

Comment 7 by woxxom@gmail.com, Jan 25 2017

The dollar sign is an invalid character for a host name as per RFC spec [1] so decodeURI naturally should not decode %24 to $. You can use decodeURIComponent which will decode it.

In Chrome .href and .origin are calculated properties that return sanitized data. For example, international hostnames in Unicode will be returned in their actual http://xn--.... format. You can use .getAttribute('href') to get the original value.

In Firefox .href and .origin in this case return an invalid host name containing invalid characters. However decodeURI('http://foo%24') doesn't decode %24 as well, which is correct behavior.

It'd be nice if a knowledgeable chromium developer commented on whether there is a spec that regulates .href and .origin results.

  [1]: https://tools.ietf.org/html/rfc952 - see the <name> rule.
Thanks for the info. I just thought it was weird that '$' would get sanitized in the first place since encodeURI/decodeURI doesn't address it.

Comment 9 by tkent@chromium.org, Jan 27 2017

Components: -Blink Blink>HTML>A Blink>Network
Labels: -Needs-Feedback
Cc: kinuko@chromium.org
Owner: tyoshino@chromium.org
tyoshino, PTAL, this is a URL handling issue.
Status: Assigned (was: Unconfirmed)
I've confirmed that the behaviour is as described. I don't know what the correct behaviour is. Changing status to "Assigned".
Owner: ----
Status: Available (was: Assigned)
Reprioritization needed.

Sign in to add a comment