Closed
Bug 312124
Opened 19 years ago
Closed 19 years ago
http://www.squarefree.com/jsenv/ no longer works: "function eval must be called directly, and not by way of a function of another name"
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
RESOLVED
FIXED
mozilla1.8rc1
People
(Reporter: jruderman, Assigned: mrbkap)
References
()
Details
(Keywords: fixed1.8, regression, testcase, Whiteboard: [patch])
Attachments
(2 files, 1 obsolete file)
311 bytes,
text/html
|
Details | |
2.29 KB,
patch
|
caillon
:
review+
brendan
:
superreview+
asa
:
approval1.8rc1+
|
Details | Diff | Splinter Review |
Steps to reproduce:
1. Go to http://www.squarefree.com/jsenv/
2. Click "Execute"
Expected: Print 0, 1, 4, 9, 16
Result: "Error on line 1: function eval must be called directly, and not by way
of a function of another name"
Regression range:
PASS: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b3)
Gecko/20050714 Firefox/1.0+
FAIL: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b4)
Gecko/20050715 Firefox/1.0+
Reporter | ||
Comment 1•19 years ago
|
||
Reporter | ||
Updated•19 years ago
|
Flags: blocking1.8rc1?
Assignee | ||
Comment 2•19 years ago
|
||
So the problem here is that the javascript URL principals inherit the principals
of their owner (the attachment page) and the iframe has about:blank principals,
so eval does not think that its principals (of the attachment page) can subsume
the principals of the scope object (the about:blank window) and says, "go away,
you can't do that."
Brendan and I were talking about making the principals of newly-opened windows
be that of their parent document (e.g., the attachment page for the iframe in
the testcase) or their opener if there was no parent document. I think this
should be possible with changes (in docshell?). Thoughts appreciated.
Assignee: general → mrbkap
Priority: -- → P2
Target Milestone: --- → mozilla1.8rc1
Comment 3•19 years ago
|
||
This would only be for about:blank pages, right?
I'd have to think through changing the security context of those pretty
carefully....
Assignee | ||
Comment 4•19 years ago
|
||
Right. As soon as a page has loaded something in it, it would have new
principals (which would be subject to all of the same-origin checks that we do now).
Reporter | ||
Comment 5•19 years ago
|
||
How about treating about:blank like a data: URL? With data: URLs, if the page
has both a parent and an opener, I think the opener's principal is used.
Reporter | ||
Comment 6•19 years ago
|
||
Are you saying that about:blank would have no principals defined until a script
"claims" it by loading a JavaScript URL, sticking nodes in, etc? I guess that
could work too, but it might be more complicated than it needs to be.
Updated•19 years ago
|
Flags: blocking1.8rc1? → blocking1.8rc1+
Assignee | ||
Comment 8•19 years ago
|
||
Actually, this is more easily implemented in nsPrincipal::Subsume().
Non-about:blank principals subsuming about:blank principals fixes this bug. I'm
still cleaning up my patch, and I still need to make sure that this isn't going
to open up any security problems.
Status: NEW → ASSIGNED
Reporter | ||
Comment 9•19 years ago
|
||
Assignee | ||
Comment 10•19 years ago
|
||
Jesse, the approach in comment 5 is incompatible with current behavior. This
patch is specific to the |eval| and |new Script| cases (bringing them up to
speed with our current treatment of about:blank documents, which is the
"anybody can touch me" treatment). This approach is compatible, and, I believe
fixes the original oversight in Subsume() [see also
nsScriptSecurityManager::CheckSameOriginPrincipalInternal].
Attachment #199367 -
Flags: review?(caillon)
Reporter | ||
Comment 11•19 years ago
|
||
Fair enough. I'll file a new bug for treating about:blank differently, since
that change would affect compatibility.
Comment 12•19 years ago
|
||
Comment on attachment 199367 [details] [diff] [review]
Potential patch
sr=me if it helps (I originated subsumes).
We should endeavor on the trunk to undo this change, by making about: URLs like
data: URLs (and javascript: URls on a good day): their origin is the origin of
the script that loaded them, or if statically src'ed, the origin of the
embedding or parent doc.
We should make not-a-principal real on the trunk too. Followup bugs welcome.
/be
Attachment #199367 -
Flags: superreview+
Comment 13•19 years ago
|
||
Comment on attachment 199367 [details] [diff] [review]
Potential patch
> NS_IMETHODIMP
> nsPrincipal::Subsumes(nsIPrincipal *aOther, PRBool *aResult)
> {
>+ // First, check if aOther is an about:blank principal. If it is, then we can
>+ // subsume it.
>+
>+ nsCOMPtr<nsIURI> otherOrigin;
>+ aOther->GetURI(getter_AddRefs(otherOrigin));
>+
>+ if (otherOrigin) {
>+ PRBool isAbout = PR_FALSE;
>+ if (NS_SUCCEEDED(otherOrigin->SchemeIs("about", &isAbout)) && isAbout) {
>+ nsCAutoString str;
>+ otherOrigin->GetSpec(str);
>+
>+ // Note: about:blank principals do not necessarily subsume about:blank
>+ // principals (unless aOther == this, which is checked in the Equals call
>+ // below).
>+
>+ if (str.Equals("about:blank")) {
>+ PRBool isEqual = PR_FALSE;
>+ if (NS_SUCCEEDED(otherOrigin->Equals(mCodebase, &isEqual)) && !isEqual) {
>+ return PR_TRUE;
Argh, you are in a NS_IMETHODIMP -- need to set *aResult and return NS_OK.
Attachment #199367 -
Flags: superreview+ → superreview-
Assignee | ||
Comment 14•19 years ago
|
||
Comment on attachment 199367 [details] [diff] [review]
Potential patch
Quite.
Attachment #199367 -
Attachment is obsolete: true
Attachment #199367 -
Flags: superreview-
Assignee | ||
Comment 15•19 years ago
|
||
Attachment #199390 -
Flags: superreview?(brendan)
Attachment #199390 -
Flags: review?(caillon)
Assignee | ||
Updated•19 years ago
|
Attachment #199367 -
Flags: review?(caillon) → superreview-
Comment 16•19 years ago
|
||
Comment on attachment 199390 [details] [diff] [review]
With COM rules followed
You probably don't need to initialize PRBool isAbout or PRBool isEqual. If the
methods fail, you won't look at their value, but if they succeed, COM rules
should warrant you get a valid value in them. But that's a very minor nit.
r=caillon
Attachment #199390 -
Flags: review?(caillon) → review+
Assignee | ||
Updated•19 years ago
|
Whiteboard: [patch]
Comment 17•19 years ago
|
||
Comment on attachment 199390 [details] [diff] [review]
With COM rules followed
I say don't trust nsIURI impls, they could come from anything (some wacky
plugin). The cost of initializing is teeny. sr=me.
/be
Attachment #199390 -
Flags: superreview?(brendan)
Attachment #199390 -
Flags: superreview+
Attachment #199390 -
Flags: approval1.8rc1?
Assignee | ||
Comment 18•19 years ago
|
||
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Updated•19 years ago
|
Attachment #199390 -
Flags: approval1.8rc1? → approval1.8rc1+
Reporter | ||
Comment 20•19 years ago
|
||
Filed followup bug 313070, "Treat about:blank like a data: URL".
You need to log in
before you can comment on or make changes to this bug.
Description
•