aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2022-03-09 21:00:46 +0000
committerMichael Williamson <mike@zwobble.org>2022-03-09 21:00:46 +0000
commit8e95f5abce943c9d2bf8dc859d628085beb15901 (patch)
tree4a636cb5490b9fbf55b2ac816f8010d716dc76c9
parente5e1601624e6dde4c888da2f3d27b1709b37127f (diff)
Ignore w:u elements when w:val is missing
-rw-r--r--NEWS4
-rw-r--r--mammoth/docx/body_xml.py2
-rw-r--r--tests/docx/body_xml_tests.py4
3 files changed, 7 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 388a2a0..a30c011 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+# 1.4.19
+
+* Ignore w:u elements when w:val is missing.
+
# 1.4.18
* Emit warning instead of throwing exception when image file cannot be found for
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index 8d727a5..c11e9e5 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -127,7 +127,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
return element and element.attributes.get("w:val") not in ["false", "0"]
def read_underline_element(element):
- return element and element.attributes.get("w:val") not in ["false", "0", "none"]
+ return element and element.attributes.get("w:val") not in [None, "false", "0", "none"]
def paragraph(element):
properties = element.find_child_or_null("w:pPr")
diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py
index e0328fb..d7f5509 100644
--- a/tests/docx/body_xml_tests.py
+++ b/tests/docx/body_xml_tests.py
@@ -275,9 +275,9 @@ class RunTests(object):
assert_equal(False, run.is_underline)
@istest
- def run_is_underlined_if_underline_element_is_present_without_val_attribute(self):
+ def run_is_not_underlined_if_underline_element_is_present_without_val_attribute(self):
run = self._read_run_with_properties([xml_element("w:u")])
- assert_equal(True, run.is_underline)
+ assert_equal(False, run.is_underline)
@istest
def run_is_not_underlined_if_underline_element_is_present_and_val_is_false(self):