Skip to content

Commit 8519487

Browse files
committed
Ignore w:u elements when w:val is missing
1 parent deff5d7 commit 8519487

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* Emit warning instead of throwing exception when image file cannot be found for
1010
a:blip elements.
1111

12+
* Ignore w:u elements when w:val is missing.
13+
1214
# 1.4.2
1315

1416
* Support soft hyphens.

src/main/java/org/zwobble/mammoth/internal/docx/StatefulBodyXmlReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private boolean isUnderline(XmlElementLike properties) {
209209
return properties.findChild("w:u")
210210
.map(child -> child.getAttributeOrNone("w:val")
211211
.map(value -> !value.equals("false") && !value.equals("0") && !value.equals("none"))
212-
.orElse(true))
212+
.orElse(false))
213213
.orElse(false);
214214
}
215215

src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,12 @@ public void runIsNotUnderlinedIfUnderlineElementIsNotPresent() {
579579
}
580580

581581
@Test
582-
public void runIsUnderlinedIfUnderlineElementIsPresentWithoutValAttribute() {
582+
public void runIsNotUnderlinedIfUnderlineElementIsPresentWithoutValAttribute() {
583583
XmlElement element = runXmlWithProperties(element("w:u"));
584584

585585
assertThat(
586586
readSuccess(bodyReader(), element),
587-
hasProperty("underline", equalTo(true))
587+
hasProperty("underline", equalTo(false))
588588
);
589589
}
590590

0 commit comments

Comments
 (0)