js2xml icon indicating copy to clipboard operation
js2xml copied to clipboard

Support \f (form feed character)

Open Gallaecio opened this issue 3 years ago • 0 comments

>>> js2xml.parse(r'var a = "\f";')
Traceback (most recent call last):
  File "src/lxml/builder.py", line 175, in lxml.builder.ElementMaker.__init__.add_text
  File "src/lxml/etree.pyx", line 1165, in lxml.etree._Element.__getitem__
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/__init__.py", line 18, in parse
    xml = _visitor.visit(tree)
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 23, in visit
    return getattr(self, method, self.generic_visit)(node)
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 31, in visit_ES5Program
    program.extend(self.visit(child))
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 23, in visit
    return getattr(self, method, self.generic_visit)(node)
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 41, in visit_VarStatement
    return [el for child in node for el in self.visit(child)]
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 41, in <listcomp>
    return [el for child in node for el in self.visit(child)]
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 23, in visit
    return getattr(self, method, self.generic_visit)(node)
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 47, in visit_VarDecl
    varel.extend(self.visit(node.initializer))
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 23, in visit
    return getattr(self, method, self.generic_visit)(node)
  File "/home/adrian/.local/share/venv/lib/python3.9/site-packages/js2xml/xmlvisitor.py", line 254, in visit_String
    return [E.string(unescape_string(str_value))]
  File "src/lxml/builder.py", line 228, in lxml.builder.ElementMaker.__call__
  File "src/lxml/builder.py", line 177, in lxml.builder.ElementMaker.__init__.add_text
  File "src/lxml/etree.pyx", line 1018, in lxml.etree._Element.text.__set__
  File "src/lxml/apihelpers.pxi", line 710, in lxml.etree._setNodeText
  File "src/lxml/apihelpers.pxi", line 698, in lxml.etree._createTextNode
  File "src/lxml/apihelpers.pxi", line 1493, in lxml.etree._utf8
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

Gallaecio avatar Jan 18 '21 13:01 Gallaecio