summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2021-09-02 20:12:41 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-09-03 13:59:32 +0200
commit0ffc7eac2596ff590eb7c7612940c7d785fea167 (patch)
treeda9a5dc051b612e2f4ba3b738e94b90938eb32be
parent9fab31d1f5cfb6e054da87082f9e77d29e150c9b (diff)
Handling exception on invalid values of the fields
There are situations where a field has an invalid value. In such a case, an exception is occurs, the program halts execution, and the output will be incomplete. With this fix, if a key is not found for the dict, name="INVALID" will be use in the output XML. This is an example execution for attachment 171572 from tdf#142021 , "EMF with PolyfillMode set to 0 before the bottom star record" PolygonFillMode can be either 1 or 2, but the field value has the value of 0. PolygonFillMode = { 0x01: "ALTERNATE", 0x02: "WINDING" } $ /opt/libreoffice7.2/program/python ./emf-dump.py star_pfm0.emf Traceback (most recent call last): File "./emf-dump.py", line 29, in <module> main(sys.argv) File "./emf-dump.py", line 25, in main dumper.dump() File "./emf-dump.py", line 20, in dump strm.dump() File "msodumper/emfrecord.py", line 76, in dump handler.dump() File "msodumper/emfrecord.py", line 400, in dump self.printAndSet("PolygonFillMode", self.readuInt32(), dict=PolygonFillMode) File "msodumper/binarystream.py", line 32, in printAndSet attrs += ' name="%s"' % dict[value] KeyError: 0 Change-Id: Id965ba0c47eace3029dd5fa12266f1a144eee41e Reviewed-on: https://gerrit.libreoffice.org/c/mso-dumper/+/121529 Tested-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--msodumper/binarystream.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/msodumper/binarystream.py b/msodumper/binarystream.py
index bdd8f37..4946a45 100644
--- a/msodumper/binarystream.py
+++ b/msodumper/binarystream.py
@@ -29,7 +29,7 @@ class BinaryStream:
attrs = ""
if dict:
if value in dict or default is None:
- attrs += ' name="%s"' % dict[value]
+ attrs += ' name="%s"' % dict.get(value, "INVALID")
else:
attrs += ' name="%s"' % default
if hexdump and type(value) != float: