Skip to content
Snippets Groups Projects
Commit e95bbaee authored by srosse's avatar srosse
Browse files

no-jira: catch number format exception

parent 065db8c6
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ import org.olat.core.gui.util.CSSHelper;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.FileUtils;
import org.olat.core.util.StringHelper;
import org.olat.core.util.io.ShieldInputStream;
import org.olat.core.util.vfs.VFSLeaf;
import org.olat.search.service.SearchResourceContext;
......@@ -87,16 +88,28 @@ public class WordOOXMLDocument extends FileDocument {
doc.setContent(0, dh.getContent());
} else if(name.startsWith(HEADER) && name.endsWith(".xml")) {
String position = name.substring(HEADER.length(), name.indexOf(".xml"));
OfficeDocumentHandler dh = new OfficeDocumentHandler();
parse(new ShieldInputStream(zip), dh);
doc.setHeader(Integer.parseInt(position), dh.getContent());
if(StringHelper.isLong(position)) {
try {
OfficeDocumentHandler dh = new OfficeDocumentHandler();
parse(new ShieldInputStream(zip), dh);
doc.setHeader(Integer.parseInt(position), dh.getContent());
} catch (NumberFormatException e) {
log.warn("", e);
//if position not a position, go head
}
}
} else if(name.startsWith(FOOTER) && name.endsWith(".xml")) {
String position = name.substring(FOOTER.length(), name.indexOf(".xml"));
OfficeDocumentHandler dh = new OfficeDocumentHandler();
parse(new ShieldInputStream(zip), dh);
doc.setFooter(Integer.parseInt(position), dh.getContent());
if(StringHelper.isLong(position)) {
try {
OfficeDocumentHandler dh = new OfficeDocumentHandler();
parse(new ShieldInputStream(zip), dh);
doc.setFooter(Integer.parseInt(position), dh.getContent());
} catch (NumberFormatException e) {
log.warn("", e);
//if position not a position, go head
}
}
}
entry = zip.getNextEntry();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment