Re: [whatwg] Question about document.referrer (and document.URL, document.location.href) when IDN domains are in use

On Fri, 12 Jul 2013, Boris Zbarsky wrote:
> On 7/12/13 2:15 PM, Ian Hickson wrote:
> > >
> > > The "document's referrer" is not really defined anywhere in a useful 
> > > way that I can find.
> >
> > What's not useful about the way it's defined? It's set to a specific 
> > string.
> I couldn't find where it was normatively set to anything.

It's normatively set in two places. For the about:blank Document, it's set 
(if necessary) here:

# If the browsing context has a creator Document, then the browsing 
# context's Document's referrer must be set to the address of that creator 
# Document at the time of the browsing context's creation.

For regular Documents, it's set in the "Creating a new Document object" 

# Set the document's referrer to the address of the resource from which 
# Request-URIs are obtained as determined when the fetch algorithm 
# obtained the resource, if that algorithm was used and determined such a 
# value; otherwise, set it to the empty string.

These seem like the logical places for it to be set. Am I missing 

> > > In cases when the hostname is non-ASCII, the Referer header will 
> > > have it encoded in punycode.
> > 
> > Is that defined anywhere?
> which 
> defines it syntactically as a URI, which means that if you have an IRI 
> you have to convert it to an IRI before putting it in there.

That's normatively imported by the HTML spec's "fetch" algorithm, so it's 
the case per HTML too. Specifically, HTML just says to generate the 
Referer header's value "as required by HTTP" using a particular URL as 
the input.

> > That's correct per spec (assuming the punycoding is required 
> > anywhere). The latter two are set separately than document.referrer:
> > 
> >'s-address
> The thing is, people are comparing origins from postMessage to origins 
> from document.referrer.  See 
> <>.  Also see 
> <>.

Well, then they'll be broken, I guess. (They'll break safe, though.)

> Also, as a note, nothing above makes it particularly clear that "the URL 
> that was originally to be fetched" is not already punycode...  Ah, well.

It might be, depends on what the URL is.

> > If other browsers don't match this, file bugs on them. :-)
> <shrug>.  It probably won't do much good, but:


On Fri, 12 Jul 2013, Adam Barth wrote:
> I don't think we're likely to change this behavior.  We always use 
> punycode for URLs except in the location bar.


On Fri, 12 Jul 2013, Boris Zbarsky wrote:
> On 7/12/13 2:40 PM, Adam Barth wrote:
> > Why not change Firefox to use punycode in window.location?
> If nothing else because that seems user-hostile (both to web developers 
> examining location values and users who are shown document.URL or 
> location.href in web pages).


On Fri, 12 Jul 2013, Anne van Kesteren wrote:
> But then we shouldn't garble pathname either and we do because we have 
> to. So I'm not sure that line of reasoning makes sense. I do think we 
> should offer some kind of conversion utility between the two.

It is unfortunate that resolving URLs does that, it's true. But just 
because we're constrained here, why should we mess up domains also?

Ian Hickson               U+1047E                )\._.,--....,'``.    fL       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 10 September 2013 19:54:54 UTC