Closed
Bug 1321550
Opened 8 years ago
Closed 8 years ago
indexedDB includes fragment identifiers in file:// URLs as hostnames
Categories
(Core :: Storage: IndexedDB, defect)
Core
Storage: IndexedDB
Tracking
()
RESOLVED
FIXED
mozilla53
Tracking | Status | |
---|---|---|
firefox53 | --- | fixed |
People
(Reporter: miker, Assigned: baku)
References
Details
Attachments
(1 file, 4 obsolete files)
1.41 KB,
patch
|
valentin
:
review+
|
Details | Diff | Splinter Review |
Creating an indexedDB under a file:/// path includes everything after a # for a domain. So going to the following URLs and creating a DB will create three completely separate DBs:
- file:///some/path/test.html
- file:///some/path/test.html#test
- file:///some/path/test.html#/test
The DBs are created at:
- file++++some+path+test.html
- file++++some+path+test.html#test
- file++++some+path+test.html#+test
Chrome and Safari instead group all file:/// indexedDBs into one location with a hostname of file__0. I think our approach is better but surely we should trim the host at the first #?
Reporter | ||
Comment 1•8 years ago
|
||
I need to know what we are supposed to do here so that I can display the correct DB info in the Storage Inspector.
OS: Windows 7 → All
Hardware: x86_64 → All
Version: 36 Branch → unspecified
Comment 2•8 years ago
|
||
This is controlled by QuotaManager and not really specific to IndexedDB. It may be related to how we treat the origin for file URLs in general. Not sure what our principal code does there. Jan, what do you think?
Flags: needinfo?(jvarga)
Comment 3•8 years ago
|
||
Yeah, this goes through QuotaManager, but we just use what nsIPrincipal::GetOrigin() gives us. We don't do anything special for file:// in QuotaManager.
I'm not an expert on file protocol, there can be a reason why it's treated this way.
We have an IndexedDB bug somewhere about file:// origins being too long.
Flags: needinfo?(jvarga)
Assignee | ||
Comment 4•8 years ago
|
||
I'll take a look at this. It seems that we are retrieving the origin wrongly for file URLs.
Flags: needinfo?(amarchesini)
Assignee | ||
Updated•8 years ago
|
Flags: needinfo?(amarchesini)
Assignee | ||
Comment 5•8 years ago
|
||
Assignee: nobody → amarchesini
Attachment #8821149 -
Flags: review?(bugs)
Comment 6•8 years ago
|
||
Comment on attachment 8821149 [details] [diff] [review]
filepath.patch
nsIURIWithQuery is so mysterious that I don't know when one is supposed to use it. I have no idea if this is right, or whether same kind of check should be done with some other schemes.
(Initial reaction is that adding explicit SchemeIs check is wrong.)
Can't really review this.
Attachment #8821149 -
Flags: review?(bugs)
Comment 7•8 years ago
|
||
So if this patch was taken (though it is confusing to reuse hostPort for filePath), which all schemes would still fallback to
nsCOMPtr<nsIStandardURL> standardURL = do_QueryInterface(origin);
NS_ENSURE_TRUE(standardURL, NS_ERROR_FAILURE);
rv = origin->GetAsciiSpec(aOrigin);
?
Comment 8•8 years ago
|
||
Do we possibly want to add GetAsciiSpecIgnoringRef and use it there and not GetAsciiSpec?
Assignee | ||
Comment 9•8 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #8)
> Do we possibly want to add GetAsciiSpecIgnoringRef and use it there and not
> GetAsciiSpec?
This would also be a nice approach. I prefer valentin to take a decision here.
Flags: needinfo?(valentin.gosu)
Comment 10•8 years ago
|
||
Yes, GetAsciiSpecIgnoringRef seems to be what we want here.
Flags: needinfo?(valentin.gosu)
Assignee | ||
Comment 11•8 years ago
|
||
Attachment #8821149 -
Attachment is obsolete: true
Attachment #8821713 -
Flags: review?(valentin.gosu)
Comment 12•8 years ago
|
||
Comment on attachment 8821713 [details] [diff] [review]
filepath2.patch
Review of attachment 8821713 [details] [diff] [review]:
-----------------------------------------------------------------
::: caps/nsPrincipal.cpp
@@ +182,5 @@
> // of the spec, and the beginning of the origin attributes) is not present
> // in the origin string
> nsCOMPtr<nsIStandardURL> standardURL = do_QueryInterface(origin);
> NS_ENSURE_TRUE(standardURL, NS_ERROR_FAILURE);
> + rv = origin->GetAsciiSpecIgnoringRef(aOrigin);
Sorry for changing my mind about this, but after seeing the patch, it seems we're adding a lot of complexity for nothing, even as bug 945240 will eventually fix this.
Anyway, I thing GetAsciiSpec and then truncating at the first `#` should do the same thing, with more or less the same overhead.
Attachment #8821713 -
Flags: review?(valentin.gosu)
Assignee | ||
Comment 13•8 years ago
|
||
Attachment #8821713 -
Attachment is obsolete: true
Attachment #8821734 -
Flags: review?(valentin.gosu)
Comment 14•8 years ago
|
||
Comment on attachment 8821734 [details] [diff] [review]
filepath3.patch
Review of attachment 8821734 [details] [diff] [review]:
-----------------------------------------------------------------
::: caps/nsPrincipal.cpp
@@ +189,3 @@
> NS_ENSURE_SUCCESS(rv, rv);
>
> + int32_t pos = spec.FindChar('?');
nit: add a comment mentioning why we are doing this.
@@ +190,5 @@
>
> + int32_t pos = spec.FindChar('?');
> + int32_t hashPos = spec.FindChar('#');
> +
> + if (pos != kNotFound && hashPos != kNotFound && hashPos < pos) {
bug: if pos==kNotFound, we never enter this branch.
Please add tests for this. We need at least 4.
file:///path?query#hash
file:///path#hash
file:///path?query
file:///path#hash?query
@@ +194,5 @@
> + if (pos != kNotFound && hashPos != kNotFound && hashPos < pos) {
> + pos = hashPos;
> + }
> +
> + if (!aOrigin.Assign(spec, pos != kNotFound ? pos : spec.Length(), fallible)) {
nit: the ternary conditional makes this harder to read.
I would have gone for GetAsciiSpec(aOrigin); find cutoff point. if (pos != kNotFound) aOrigin.Truncate(pos);
Attachment #8821734 -
Flags: review?(valentin.gosu)
Assignee | ||
Comment 15•8 years ago
|
||
Is there an easy way to write tests for file URL?
Attachment #8821734 -
Attachment is obsolete: true
Attachment #8823066 -
Flags: review?(valentin.gosu)
Assignee | ||
Comment 16•8 years ago
|
||
Attachment #8823066 -
Attachment is obsolete: true
Attachment #8823066 -
Flags: review?(valentin.gosu)
Attachment #8823067 -
Flags: review?(valentin.gosu)
Updated•8 years ago
|
Attachment #8823067 -
Flags: review?(valentin.gosu) → review+
Comment 17•8 years ago
|
||
Jan, do we need some kind of migration or cleanup for origins on disk for our old serialization?
Flags: needinfo?(jvarga)
Comment 18•8 years ago
|
||
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/974a431df67c
origin should not contain ref part of the URL, r=valentin
Comment 19•8 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #17)
> Jan, do we need some kind of migration or cleanup for origins on disk for
> our old serialization?
So before this patch we created and used separate origin directories, for example:
file++++some+path+test.html
file++++some+path+test.html#test
file++++some+path+test.html#+test
After the patch, only the first one will be used/shared.
So the 2nd and 3rd one won't be ever used again. It would be nice to delete them immediately, but I'm not sure it's worth to do it given that file:// is not used much by typical users. Anyway the unused directories should get removed once the global limit for default/temporary storage is reached.
Flags: needinfo?(jvarga)
Comment 20•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox53:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in
before you can comment on or make changes to this bug.
Description
•