Ignore:
Timestamp:
2018-10-14T15:15:50+02:00 (7 years ago)
Author:
Don-vip
Message:

see #14319, see #16838 - update to svgSalamander 1.1.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/kitfox/svg/ImageSVG.java

    r11526 r14328  
    115115            {
    116116                URI src = sty.getURIValue(getXMLBase());
    117                 // CVE-2017-5617: Allow only data scheme
    118117                if ("data".equals(src.getScheme()))
    119118                {
    120119                    imageSrc = new URL(null, src.toASCIIString(), new Handler());
    121120                }
     121                else
     122                {
     123                    if (!diagram.getUniverse().isImageDataInlineOnly())
     124                    {
     125                        try
     126                        {
     127                            imageSrc = src.toURL();
     128                        } catch (Exception e)
     129                        {
     130                            Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
     131                                "Could not parse xlink:href " + src, e);
     132                            imageSrc = null;
     133                        }
     134                    }
     135                }
    122136            }
    123137        } catch (Exception e)
     
    126140        }
    127141
    128         if (imageSrc != null)
    129         {
    130             diagram.getUniverse().registerImage(imageSrc);
    131 
    132             //Set widths if not set
    133             BufferedImage img = diagram.getUniverse().getImage(imageSrc);
    134             if (img == null)
    135             {
    136                 xform = new AffineTransform();
    137                 bounds = new Rectangle2D.Float();
    138                 return;
    139             }
    140 
    141             if (width == 0)
    142             {
    143                 width = img.getWidth();
    144             }
    145             if (height == 0)
    146             {
    147                 height = img.getHeight();
    148             }
    149 
    150             //Determine image xform
     142        diagram.getUniverse().registerImage(imageSrc);
     143
     144        //Set widths if not set
     145        BufferedImage img = diagram.getUniverse().getImage(imageSrc);
     146        if (img == null)
     147        {
    151148            xform = new AffineTransform();
    152             xform.translate(this.x, this.y);
    153             xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
    154         }
     149            bounds = new Rectangle2D.Float();
     150            return;
     151        }
     152
     153        if (width == 0)
     154        {
     155            width = img.getWidth();
     156        }
     157        if (height == 0)
     158        {
     159            height = img.getHeight();
     160        }
     161
     162        //Determine image xform
     163        xform = new AffineTransform();
     164        xform.translate(this.x, this.y);
     165        xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
    155166
    156167        bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
     
    326337                URI src = sty.getURIValue(getXMLBase());
    327338
    328                 URL newVal = null;
    329                 // CVE-2017-5617: Allow only data scheme
     339                URL newVal;
    330340                if ("data".equals(src.getScheme()))
    331341                {
    332342                    newVal = new URL(null, src.toASCIIString(), new Handler());
     343                } else
     344                {
     345                    newVal = src.toURL();
    333346                }
    334347
    335                 if (newVal != null && !newVal.equals(imageSrc))
     348                if (!newVal.equals(imageSrc))
    336349                {
    337350                    imageSrc = newVal;
Note: See TracChangeset for help on using the changeset viewer.