aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2020-04-12 15:09:16 +0100
committerMichael Williamson <mike@zwobble.org>2020-04-12 15:09:16 +0100
commit51e109968beb0c4f2fc4ac8524c3bbf1b74da369 (patch)
tree9bb7a89c0b52c3cad074fabea2380a371a5fb253 /mammoth/docx
parenta3c287007942dbe119ebdc7111f5996e083ced7e (diff)
Only parse integer font sizes
Diffstat (limited to 'mammoth/docx')
-rw-r--r--mammoth/docx/body_xml.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index 7bb8628..e65c5b2 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -81,7 +81,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
font = properties.find_child_or_null("w:rFonts").attributes.get("w:ascii")
font_size_string = properties.find_child_or_null("w:sz").attributes.get("w:val")
- if font_size_string:
+ if _is_int(font_size_string):
# w:sz gives the font size in half points, so halve the value to get the size in points
font_size = int(font_size_string) / 2
else:
@@ -602,3 +602,15 @@ def _add_attrs(obj, **kwargs):
setattr(obj, key, value)
return obj
+
+
+def _is_int(value):
+ if value is None:
+ return False
+
+ try:
+ int(value)
+ except ValueError:
+ return False
+
+ return True