Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 1015 by felix8a: NPE on some invalid object literals
http://code.google.com/p/google-caja/issues/detail?id=1015
cajoling this:
<script> var x = { valueOf: 3, b: 4 }; </script>
causes a NullPointerException.
the culprit is Rule mapPlural in CajitaRewriter.
mapPlural uses Rule.substSingleMap to do expansion on each
key:value pair individually.
this individual expansion triggers the rule that denies "valueOf",
so the expansion doesn't return any values.
mapPlural complains, continues, adds nulls to the list it's building,
which it will substitute into "___.initializem...@items*]"
the finished list gets handed to ParseTreeNodeContainer,
which checks for null elements and throws an NPE.
this patch fixes the NPE and also changes the alarming
MAP_RECURSION_FAILED message, which looks like this:
FATAL_ERROR: x.html:2+11 - 18: The valueOf property must not be set: Rule
"mapBadKeyValueOf", StringLiteral : 'valueOf'
FATAL_ERROR: x.html:2+9 - 30: INTERNAL COMPILER ERROR. Object literal
decomposition did
not match any rules at: ObjectConstructor
StringLiteral : 'valueOf'
IntegerLiteral : 3
StringLiteral : 'foo'
IntegerLiteral : 4. Please report this error at:
http://code.google.com/p/google-caja/issues/
the INTERNAL COMPILER ERROR is redundant in this case,
but it's not clear to me that it will always be redundant,
so I reworded it to something meaningful but less alarming.
Attachments:
npe_obj_literal.patch 3.8 KB
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings