sixcooler 9 years ago
commit 1091e25f4c

@ -155,6 +155,7 @@ public class svgParser extends AbstractParser implements Parser {
private final StringBuilder buffer = new StringBuilder(); private final StringBuilder buffer = new StringBuilder();
private boolean scrapeMetaData = false; // true if within metadata tag private boolean scrapeMetaData = false; // true if within metadata tag
private boolean svgStartTagFound = false; // switch to recognize start tag processing, to cancel parsing on wrong tag
private String docTitle = null; // document level title private String docTitle = null; // document level title
private String docDescription = null; // document level description private String docDescription = null; // document level description
@ -175,9 +176,10 @@ public class svgParser extends AbstractParser implements Parser {
// not implemented yet TODO: interprete RDF content // not implemented yet TODO: interprete RDF content
// may contain RDF + DC, DC, CC ... // may contain RDF + DC, DC, CC ...
} else { } else {
if (null != tag) { if (tag != null) {
switch (tag) { switch (tag) {
case "svg": case "svg":
svgStartTagFound = true;
imgHeight = atts.getValue("height"); imgHeight = atts.getValue("height");
imgWidth = atts.getValue("width"); imgWidth = atts.getValue("width");
break; break;
@ -190,6 +192,11 @@ public class svgParser extends AbstractParser implements Parser {
case "path": case "path":
case "rect": case "rect":
throw new SAXException("EOF svg Metadata", new EOFException()); throw new SAXException("EOF svg Metadata", new EOFException());
default : { // K.O. criteria, start tag is not svg, fail parser on none svg
if (!svgStartTagFound) {
throw new SAXException("not a svg file, start tag "+tag, new Failure());
}
}
} }
} }
} }

Loading…
Cancel
Save