Closed
Bug 705355
Opened 12 years ago
Closed 11 years ago
Use IDL for Components.utils.evalInSandbox
Categories
(Core :: XPConnect, defect)
Core
XPConnect
Tracking
()
RESOLVED
FIXED
mozilla11
People
(Reporter: Ms2ger, Assigned: Ms2ger)
References
Details
Attachments
(1 file, 2 obsolete files)
5.86 KB,
patch
|
bholley
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Attachment #576989 -
Flags: review?(bobbyholley+bmo)
Assignee | ||
Comment 1•12 years ago
|
||
Turns out that jsVersionStr or filenameStr being null isn't a failure case: <https://tbpl.mozilla.org/?tree=Try&rev=cb53dfe085f5>
Attachment #577047 -
Flags: review?(bobbyholley+bmo)
Assignee | ||
Updated•12 years ago
|
Attachment #576989 -
Attachment is obsolete: true
Attachment #576989 -
Flags: review?(bobbyholley+bmo)
Comment 2•12 years ago
|
||
Comment on attachment 577047 [details] [diff] [review] Patch v2 The aFoo names needs to be removed here as well. >+ JSString *jsVersionStr = JS_ValueToString(aCx, aVersion); >+ JSString *filenameStr = JS_ValueToString(aCx, aFilename); >+ PRInt32 lineNo = aLineNo; This relies on a whole host of lucky magic that is not at all explicit. In particular, it requires that XPConnect converts |[optional] in jsval| parameters to JSVAL_VOID, which is subsequently converted by JS_ValueToString() to null. It also relies on |[optional] in unsigned| being converted to JSVAL_NULL, and that ending up as zero in JS_ValueToECMAInt32 (in XPCConvert::JSData2Native). IMO, the values of optional parameters should be consider undefined if not given, and [optional_argc] should always be used. Can we use it here? r- until we get that figured out.
Attachment #577047 -
Flags: review?(bobbyholley+bmo) → review-
Assignee | ||
Comment 3•12 years ago
|
||
I disagree. We rely on the default value of optional parameters pretty much everywhere we use optional parameters. I don't see how adding more complexity here is useful.
Comment 4•12 years ago
|
||
Comment on attachment 577047 [details] [diff] [review] Patch v2 (In reply to Ms2ger from comment #3) > I disagree. We rely on the default value of optional parameters pretty much > everywhere we use optional parameters. I don't see how adding more > complexity here is useful. Looks like you're right. Sorry about that. Still, if we're going to rely in this stuff, it should at least be documented. Can you update https://developer.mozilla.org/en/XPIDL to specify the default values (post XPCConvert) that we get when we omit optional arguments? Also, please add a comment here noting that jsvals default to JSVAL_VOID (which converts to the NULL JSString) and integers default to zero: > + JSString *jsVersionStr = JS_ValueToString(aCx, aVersion); > + JSString *filenameStr = JS_ValueToString(aCx, aFilename); > + PRInt32 lineNo = aLineNo; r+ with that. :-)
Attachment #577047 -
Flags: review- → review+
Assignee | ||
Comment 5•12 years ago
|
||
That version actually didn't really work out; this one passes try.
Attachment #577047 -
Attachment is obsolete: true
Attachment #579394 -
Flags: review?(bobbyholley+bmo)
Comment 6•12 years ago
|
||
Comment on attachment 579394 [details] [diff] [review] Patch v3 >- >- >- // Optional fourth and fifth arguments: filename and line number. >- if (filenameStr) { >+ PRInt32 lineNo; >+ if (optionalArgc >= 2) { >+ JSString *filenameStr = JS_ValueToString(cx, filenameVal); >+ if (!filenameStr) >+ return NS_ERROR_INVALID_ARG; >+ >+ JSAutoByteString filenameBytes; > if (!filenameBytes.encode(cx, filenameStr)) > return NS_ERROR_INVALID_ARG; > filename = filenameBytes.ptr(); >+ lineNo = lineNumber; The use of lineNumber here in the case of optional_argc == 2 might be correct here, but it looks suspicious given that the rest of the code depends on optional_argc. As such, I'd prefer to structure this so that we first check optional_argc >= 2 (and do the filename stuff), then check optional_argc >= 3 (and save the filename). Afterwards, we check if optional_argc < 3, and if so, grab anything we're missing. r+ with that.
Attachment #579394 -
Flags: review?(bobbyholley+bmo) → review+
Assignee | ||
Comment 7•11 years ago
|
||
(In reply to Bobby Holley (:bholley) from comment #6) > Comment on attachment 579394 [details] [diff] [review] > Patch v3 > The use of lineNumber here in the case of optional_argc == 2 might be > correct here, but it looks suspicious given that the rest of the code > depends on optional_argc. > > As such, I'd prefer to structure this so that we first check optional_argc > >= 2 (and do the filename stuff), then check optional_argc >= 3 (and save > the filename). Afterwards, we check if optional_argc < 3, and if so, grab > anything we're missing. We agreed on IRC that this was fine. https://hg.mozilla.org/mozilla-central/rev/935634dccf0c
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla11
You need to log in
before you can comment on or make changes to this bug.
Description
•