Closed Bug 488216 Opened 15 years ago Closed 15 years ago

globalStorage is broken for hostnames ending with a period (throws NS_ERROR_DOM_SECURITY exception when accessing)

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: sephr, Assigned: mayhemer)

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.8) Gecko/2009032712 Ubuntu/8.10 (intrepid) Firefox/3.0.8 GTB5
Build Identifier: 

For hostnames ending with a period, globalStorage[location.hostname] throws NS_ERROR_DOM_SECURITY.
This makes globalStorage offline storage completely broken with no workaround if the hostname happens to end with a period.

Reproducible: Always

Actual Results:  
NS_ERROR_DOM_SECURITY

Expected Results:  
globalStorage[location.hostname] works fine.
Component: Embedding: GTK Widget → JavaScript Engine
Severity: major → normal
How can DNS hostnames end in a period?
Component: JavaScript Engine → DOM
QA Contact: gtk-widget → general
(In reply to comment #1)
> How can DNS hostnames end in a period?

When you use OpenDNS (they treat it as if it wasn't there so example.com. works) or have custom hosts. I have "." set to Google.
(In reply to comment #2)
> (In reply to comment #1)
> > How can DNS hostnames end in a period?
> 
> When you use OpenDNS (they treat it as if it wasn't there so example.com.
> works) or have custom hosts. I have "." set to Google.

All hostnames canonically end with ".".  By explicitly including the "." at the end, you can specify an absolute hostname.  Ones that don't end with "." are relative, usually to some suffix that the OS uses.  (Set for example on my Linux machine with the "search" line in /etc/resolv.conf.)
(In reply to comment #3)
I think I'm misunderstanding this, but are you implying that "foo.example." should be allowed to access globalStorage["foo.example"]? Either way, it can't access globalStorage["foo.example"] or globalStorage["foo.example."] until this bug is fixed. Also, if an ending dot is supposed to be ignored in this case, than "." would be allowed to access globalStorage[""].
(In reply to comment #4)
> I think I'm misunderstanding this, but are you implying that "foo.example."
> should be allowed to access globalStorage["foo.example"]?

Ah I don't know about that; I haven't read what the spec says.  All I'm saying is that hostnames in the DNS definitely end in a period, and thus most of the time a request to look up the records for "foo.example" is really a request to look up "foo.example.".

Whether that's a useful distinction to make for globalStorage, I don't know.

> Either way, it can't access globalStorage["foo.example"] or
> globalStorage["foo.example."] until this bug is fixed. Also, if an ending
> dot is supposed to be ignored in this case, than "." would be allowed to
> access globalStorage[""].

The name of the root zone is ".", but I don't think "" is a valid domain name.
Perhaps WONTFIX, because you should use localStorage now?
Whiteboard: [wontfix?]
(In reply to comment #6)
> Perhaps WONTFIX, because you should use localStorage now?

Well localStorage doesn't "work" with domains that end in a period in that they are the same domain but they can't access the same localStorage.

For example:
 - Open http://code.eligrey.com./shell/shell.html and http://code.eligrey.com/shell/shell.html in two different tabs.
 - Type localStorage.setItem("foo", "bar") in one of the tabs.
 - Type localStorage.getItem("foo") in the other tab. You get null instead of "bar".

I think that both pages should both have access to the same localStorage.
Could you file a separate bug on that? Do other domain-restricted things work in this case? (cookies, same-origin checks, etc.)
Component: DOM → DOM: Mozilla Extensions
BTW, the behavior described in comment 0 still happens in Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.3a1pre) Gecko/20090919 Minefield/3.7a1pre, confirming.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: globalStorage is broken for hostnames ending with a period → globalStorage is broken for hostnames ending with a period (throws NS_ERROR_DOM_SECURITY exception when accessing)
Whiteboard: [wontfix?]
I just remembered that TLDs can actually function as websites as long as you include an explicit ending period. This bug makes it impossible for http://ai./ to use globalStorage.
I would close this as WONTFIX. globalStorage is no more a maintained code. There is no chance to make any changes in its implementation. Use localStorage instead.

However, there is the same 'bug' when using localStorage. When I confirm it I will create a bug for it.

The main problem here is that we cannot distinguish between a relative and an absolute name. 'example.com.' is the same as 'example.com' when it has been found by the server. If there is a default suffix defined, say 'com' for instance, then 'example' is the same as 'example.com' or 'example.com.' but not as 'example.'.
Assignee: nobody → honzab.moz
Closing as WONTFIX.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → WONTFIX
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.