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

RESOLVED WONTFIX

Status

()

RESOLVED WONTFIX
10 years ago
6 years ago

People

(Reporter: sephr, Assigned: mayhemer)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

10 years ago
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.
(Reporter)

Updated

10 years ago
Component: Embedding: GTK Widget → JavaScript Engine
(Reporter)

Updated

10 years ago
Severity: major → normal

Comment 1

10 years ago
How can DNS hostnames end in a period?

Updated

10 years ago
Component: JavaScript Engine → DOM
QA Contact: gtk-widget → general
(Reporter)

Comment 2

10 years ago
(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.)
(Reporter)

Comment 4

10 years ago
(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?]
(Reporter)

Comment 7

9 years ago
(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?]
(Reporter)

Comment 10

9 years ago
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.
(Assignee)

Comment 11

9 years ago
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)

Updated

9 years ago
Assignee: nobody → honzab.moz
(Assignee)

Comment 12

9 years ago
Closing as WONTFIX.
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → WONTFIX
Component: DOM: Mozilla Extensions → DOM
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.