Ticket #19097: 19097.patch

File 19097.patch, 1.5 KB (added by GerdP, 6 years ago)

avoid to show lots of garbarge on the console when url starts with "data:image/svg+xml" but contains a PNG file

  • src/org/openstreetmap/josm/tools/ImageProvider.java

     
    6464import javax.swing.ImageIcon;
    6565import javax.xml.parsers.ParserConfigurationException;
    6666
    67 import com.kitfox.svg.SVGDiagram;
    68 import com.kitfox.svg.SVGException;
    69 import com.kitfox.svg.SVGUniverse;
    7067import org.openstreetmap.josm.data.Preferences;
    7168import org.openstreetmap.josm.data.osm.DataSet;
    7269import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    9087import org.xml.sax.XMLReader;
    9188import org.xml.sax.helpers.DefaultHandler;
    9289
     90import com.kitfox.svg.SVGDiagram;
     91import com.kitfox.svg.SVGException;
     92import com.kitfox.svg.SVGUniverse;
     93
    9394/**
    9495 * Helper class to support the application with images.
    9596 *
     
    10161017            String mediatype = m.group(1);
    10171018            if ("image/svg+xml".equals(mediatype)) {
    10181019                String s = new String(bytes, StandardCharsets.UTF_8);
     1020                // see #19097: check if s starts with PNG magic
     1021                if (s.length() > 4 && "PNG".equals(s.substring(1, 4))) {
     1022                    Logging.warn("url contains PNG file " + url);
     1023                    return null;
     1024                }
    10191025                SVGDiagram svg;
    10201026                synchronized (getSvgUniverse()) {
    10211027                    URI uri = getSvgUniverse().loadSVG(new StringReader(s), Utils.encodeUrl(s));