diff options
author | Tim Allison <tallison@apache.org> | 2016-10-31 19:02:06 +0000 |
---|---|---|
committer | Tim Allison <tallison@apache.org> | 2016-10-31 19:02:06 +0000 |
commit | 6452b4c62f5f36de0aa193c8708f7e3a9125411b (patch) | |
tree | c69c57e763d53319651d7bf5f7141a9b38fb124f /src/ooxml/java | |
parent | 1c3d84671ec0fe6b1d909bc8010f44aa71b6a24a (diff) | |
download | poi-6452b4c62f5f36de0aa193c8708f7e3a9125411b.tar.gz poi-6452b4c62f5f36de0aa193c8708f7e3a9125411b.zip |
60293 -- Handle illegal "Odd" header/footer in XWPF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1767353 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java')
-rw-r--r-- | src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java index 8ff59713af..682b1cfd48 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java +++ b/src/ooxml/java/org/apache/poi/xwpf/model/XWPFHeaderFooterPolicy.java @@ -29,6 +29,7 @@ import org.apache.poi.xwpf.usermodel.XWPFHeader; import org.apache.poi.xwpf.usermodel.XWPFHeaderFooter; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRelation; +import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef; @@ -115,8 +116,14 @@ public class XWPFHeaderFooterPolicy { if (relatedPart != null && relatedPart instanceof XWPFHeader) { hdr = (XWPFHeader) relatedPart; } - // Assign it - Enum type = ref.getType(); + // Assign it; treat invalid options as "default" POI-60293 + Enum type; + try { + type = ref.getType(); + } catch (XmlValueOutOfRangeException e) { + type = STHdrFtr.DEFAULT; + } + assignHeader(hdr, type); } for (int i = 0; i < sectPr.sizeOfFooterReferenceArray(); i++) { @@ -127,8 +134,13 @@ public class XWPFHeaderFooterPolicy { if (relatedPart != null && relatedPart instanceof XWPFFooter) { ftr = (XWPFFooter) relatedPart; } - // Assign it - Enum type = ref.getType(); + // Assign it; treat invalid options as "default" POI-60293 + Enum type; + try { + type = ref.getType(); + } catch (XmlValueOutOfRangeException e) { + type = STHdrFtr.DEFAULT; + } assignFooter(ftr, type); } } |