Closed Bug 305583 Opened 19 years ago Closed 19 years ago

allow explicit use of XMLList constructor with E4X disabled

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: sync2d, Assigned: mrbkap)

References

()

Details

(Keywords: fixed1.8)

Attachments

(1 file)

Explicit use of the XMLList constructor with E4X disabled should be
allowed, like explicit use of the XML constructor (see bug 301574).

In other words,
 data:text/html,<script>alert(XMLList("<p>text</p>"));</script>
should work without an error "invalid XML markup".
Attached patch do the toggle!Splinter Review
I should have done this when I did the same thing for the XML constructor. It
looks like XML and XMLList should have the same behavior here (wrt the XML
option).
Assignee: general → mrbkap
Status: UNCONFIRMED → ASSIGNED
Attachment #193584 - Flags: review?(brendan)
Comment on attachment 193584 [details] [diff] [review]
do the toggle!

>@@ -7035,22 +7036,27 @@ XMLList(JSContext *cx, JSObject *obj, ui
>                     return JS_FALSE;
>                 *rval = OBJECT_TO_JSVAL(listobj);
> 
>                 list = (JSXML *) JS_GetPrivate(cx, listobj);
>                 if (!Append(cx, list, xml))
>                     return JS_FALSE;
>                 return JS_TRUE;
>             }
>         }
>     }

Blank line here, please.

>+    /* Toggle on XML support since the script has explicitly requested it. */
>+    oldopts = cx->options;
>+    JS_SetOptions(cx, oldopts | JSOPTION_XML);
> 
>     listobj = ToXMLList(cx, v);
>+
>+    JS_SetOptions(cx, oldopts);
>     if (!listobj)
>         return JS_FALSE;

Super-nit: I'd crunch everything above together, and put a blank line here
instead.

>     *rval = OBJECT_TO_JSVAL(listobj);
>     return JS_TRUE;
> }

/be
Attachment #193584 - Flags: review?(brendan)
Attachment #193584 - Flags: review+
Attachment #193584 - Flags: approval1.8b4+
Fix checked into MOZILLA_1_8_BRANCH and trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Keywords: fixed1.8
Resolution: --- → FIXED
test covered in js1_6/Regress/regress-301574.js

Checking in regress-301574.js;
/cvsroot/mozilla/js/tests/js1_6/Regress/regress-301574.js,v  <--  regress-301574.js
new revision: 1.2; previous revision: 1.1
done
Flags: testcase+
(In reply to comment #4)
> test covered in js1_6/Regress/regress-301574.js

http://lxr.mozilla.org/mozilla/source/js/tests/js1_6/Regress/regress-301574.js
 58 try
 59 {
 60   var xml = XML('<p>text</p>');
 61 }
 62 catch(e)
 63 {
 64   actual = 'error: ' + e;
 65 }  
 66 
 67 reportCompare(expect, actual, summary + ': XMLList()');
line 60 should call XMLList()...
(In reply to comment #5)

Checking in regress-301574.js;
/cvsroot/mozilla/js/tests/js1_6/Regress/regress-301574.js,v  <--  regress-301574.js
new revision: 1.3; previous revision: 1.2
done

thanks shutdown.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: