Banned E4X from being used in apps.
This commit is contained in:
Родитель
6a9ba3e82a
Коммит
c294750842
|
@ -113,3 +113,9 @@ DEFINITIONS = {
|
||||||
"XMLName": node(branches=("contents", )),
|
"XMLName": node(branches=("contents", )),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
E4X_NODES = set(["XMLElement", "XMLList", "XMLStartTag", "XMLEndTag",
|
||||||
|
"XMLPointTag", "XMLName", "XMLEscape",
|
||||||
|
"XMLDefaultDeclaration", "XMLQualifiedIdentifier",
|
||||||
|
"XMLFunctionQualifiedIdentifier",
|
||||||
|
"XMLAttributeSelector", "XMLFilterExpression"])
|
||||||
|
|
|
@ -4,7 +4,7 @@ import types
|
||||||
|
|
||||||
from . import actions
|
from . import actions
|
||||||
from .jstypes import *
|
from .jstypes import *
|
||||||
from .nodedefinitions import DEFINITIONS
|
from .nodedefinitions import DEFINITIONS, E4X_NODES
|
||||||
from .predefinedentities import GLOBAL_ENTITIES, BANNED_IDENTIFIERS
|
from .predefinedentities import GLOBAL_ENTITIES, BANNED_IDENTIFIERS
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,6 +90,17 @@ class Traverser:
|
||||||
self.line = self.start_line + int(node["loc"]["start"]["line"])
|
self.line = self.start_line + int(node["loc"]["start"]["line"])
|
||||||
self.position = int(node["loc"]["start"]["column"])
|
self.position = int(node["loc"]["start"]["column"])
|
||||||
|
|
||||||
|
if node["type"] in E4X_NODES:
|
||||||
|
self.err.error(
|
||||||
|
err_id=("js", "traverser", "e4x"),
|
||||||
|
error="E4X banned from app use.",
|
||||||
|
description="E4X has been deprecated and removed from Gecko. "
|
||||||
|
"It may not be used in apps.",
|
||||||
|
filename=self.filename,
|
||||||
|
line=self.line,
|
||||||
|
column=self.position,
|
||||||
|
context=self.context)
|
||||||
|
|
||||||
# Extract properties about the node that we're traversing
|
# Extract properties about the node that we're traversing
|
||||||
(branches, establish_context, action, returns,
|
(branches, establish_context, action, returns,
|
||||||
block_level) = DEFINITIONS[node["type"]]
|
block_level) = DEFINITIONS[node["type"]]
|
||||||
|
|
|
@ -9,22 +9,26 @@ class TestE4X(TestCase):
|
||||||
def test_pass(self):
|
def test_pass(self):
|
||||||
"""Test that E4X isn't immediately rejected."""
|
"""Test that E4X isn't immediately rejected."""
|
||||||
self.run_script("""var x = <foo a={x}><bar /><{zap} /></foo>;""")
|
self.run_script("""var x = <foo a={x}><bar /><{zap} /></foo>;""")
|
||||||
self.assert_silent()
|
self.assert_failed(with_errors=True)
|
||||||
|
|
||||||
def test_default_declaration(self):
|
def test_default_declaration(self):
|
||||||
"""
|
"""
|
||||||
Test that the E4X default declaration is tested as an expression.
|
Test that the E4X default declaration is tested as an expression.
|
||||||
"""
|
"""
|
||||||
self.run_script("""default xml namespace = eval("alert();");""");
|
self.run_script("""default xml namespace = eval("alert();");""");
|
||||||
self.assert_failed(with_warnings=True)
|
self.assert_failed(with_errors=True, with_warnings=True)
|
||||||
|
|
||||||
def test_xmlescape(self):
|
def test_xmlescape(self):
|
||||||
"""Test that XMLEscape nodes are evaluated."""
|
"""Test that XMLEscape nodes are evaluated."""
|
||||||
self.run_script("""var x = <foo a={x}><bar /><{eval("X")} /></foo>;""")
|
self.run_script("""var x = <foo a={x}><bar /><{eval("X")} /></foo>;""")
|
||||||
self.assert_failed(with_warnings=True)
|
self.assert_failed(with_errors=True, with_warnings=True)
|
||||||
|
|
||||||
def test_xmlname_string(self):
|
def test_xmlname_string(self):
|
||||||
"""Test that XMLName nodes with a string "contents" works."""
|
"""
|
||||||
|
Test that XMLName nodes with a string "contents" works.
|
||||||
|
|
||||||
|
This test is present solely to test for tracebacks.
|
||||||
|
"""
|
||||||
self.run_script("""
|
self.run_script("""
|
||||||
let reportData =
|
let reportData =
|
||||||
<report>
|
<report>
|
||||||
|
@ -49,7 +53,6 @@ class TestE4X(TestCase):
|
||||||
<errors/>
|
<errors/>
|
||||||
</report>;
|
</report>;
|
||||||
""")
|
""")
|
||||||
self.assert_silent()
|
|
||||||
|
|
||||||
def test_xmlattributeselector(self):
|
def test_xmlattributeselector(self):
|
||||||
"""Test that XMLAttributeSelectors don't throw tracebacks."""
|
"""Test that XMLAttributeSelectors don't throw tracebacks."""
|
||||||
|
@ -57,7 +60,6 @@ class TestE4X(TestCase):
|
||||||
var x = <foo zip="zap"><bar /></foo>;
|
var x = <foo zip="zap"><bar /></foo>;
|
||||||
var y = x.@zip;
|
var y = x.@zip;
|
||||||
""")
|
""")
|
||||||
self.assert_silent()
|
|
||||||
|
|
||||||
def test_double_colon(self):
|
def test_double_colon(self):
|
||||||
"""
|
"""
|
||||||
|
@ -69,5 +71,3 @@ class TestE4X(TestCase):
|
||||||
xmlns:nsTypes={nsTypes}/>;
|
xmlns:nsTypes={nsTypes}/>;
|
||||||
req::asdf.oijaewr::aasdf = "foo";
|
req::asdf.oijaewr::aasdf = "foo";
|
||||||
""")
|
""")
|
||||||
self.assert_silent()
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче