george-hopkins / codeplug

codeplug decoder and builder for Motorola radios
MIT License
55 stars 17 forks source link

Matrix Format Triggers lxml error #1

Closed KR0SIV closed 6 years ago

KR0SIV commented 6 years ago

While I'm easily able to decode a version 12 code plug I've been getting an error while trying this with a version 13 code plug.

Archive type is Matrix

Q:\codeplug-prepare>codeplug decode kk.ctb Traceback (most recent call last): File "c:\users\kr0siv\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\kr0siv\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\KR0SIV\AppData\Local\Programs\Python\Python36\Scripts\codeplug.exe__main__.py", line 9, in File "c:\users\kr0siv\appdata\local\programs\python\python36\lib\site-packages\codeplug.py", line 164, in main return args.func(args) File "c:\users\kr0siv\appdata\local\programs\python\python36\lib\site-packages\codeplug.py", line 121, in _decode_cmd result = decode(data, base64.b64decode(config['key']), base64.b64decode(config['iv'])) File "c:\users\kr0siv\appdata\local\programs\python\python36\lib\site-packages\codeplug.py", line 41, in decode doc = etree.fromstring(data) File "src\lxml\lxml.etree.pyx", line 3213, in lxml.etree.fromstring (src\lxml\lxml.etree.c:78994) File "src\lxml\parser.pxi", line 1848, in lxml.etree._parseMemoryDocument (src\lxml\lxml.etree.c:118325) File "src\lxml\parser.pxi", line 1736, in lxml.etree._parseDoc (src\lxml\lxml.etree.c:117005) File "src\lxml\parser.pxi", line 1102, in lxml.etree._BaseParser._parseDoc (src\lxml\lxml.etree.c:111249) File "src\lxml\parser.pxi", line 595, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:105093) File "src\lxml\parser.pxi", line 706, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:106801) File "src\lxml\parser.pxi", line 635, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:105655) File "", line 2 lxml.etree.XMLSyntaxError: xmlParseCharRef: invalid xmlChar value 19, line 2, column 35

george-hopkins commented 6 years ago

Thank you for your report. Can you share a codeplug file which doesn't work (either by attaching it here or sending it to george-hopkins@null.net)?

KR0SIV commented 6 years ago

e-mail has been sent, wanted to make sure you received it.

george-hopkins commented 6 years ago

Thank you for sending me a sample. I'm sorry I didn't respond earlier.

Motorola seems to use a rather strange approach to embed binary data in XML. Nonetheless, I think we are now able parse the format correctly.

If you want to give it a try: You can either use the code in the matrix branch or use the pre-built binary from https://ci.appveyor.com/project/george-hopkins/codeplug/build/1.0.19/artifacts You will need to specify the format explicitly when building: codeplug build -t MATRIX yourplug.xml

KR0SIV commented 6 years ago

Sorry it has taken me so long to respond. This works fantastically without issue. I've used it on quite a few codeplugs and it handles each one just as the Master branch had with other encodings.