Changeset 14334 in josm for trunk/src


Ignore:
Timestamp:
2018-10-14T21:50:40+02:00 (6 years ago)
Author:
Don-vip
Message:

see #14319, see #16838 - svgSalamander fix for CVE-2017-5617 was incomplete

See https://github.com/blackears/svgSalamander/issues/11

File:
1 edited

Legend:

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

    r14328 r14334  
    119119                    imageSrc = new URL(null, src.toASCIIString(), new Handler());
    120120                }
    121                 else
    122                 {
    123                     if (!diagram.getUniverse().isImageDataInlineOnly())
     121                else if (!diagram.getUniverse().isImageDataInlineOnly())
     122                {
     123                    try
    124124                    {
    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                         }
     125                        imageSrc = src.toURL();
     126                    } catch (Exception e)
     127                    {
     128                        Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
     129                            "Could not parse xlink:href " + src, e);
     130                        imageSrc = null;
    134131                    }
    135132                }
     
    140137        }
    141138
    142         diagram.getUniverse().registerImage(imageSrc);
    143 
    144         //Set widths if not set
    145         BufferedImage img = diagram.getUniverse().getImage(imageSrc);
    146         if (img == null)
    147         {
     139        if (imageSrc != null)
     140        {
     141            diagram.getUniverse().registerImage(imageSrc);
     142
     143            //Set widths if not set
     144            BufferedImage img = diagram.getUniverse().getImage(imageSrc);
     145            if (img == null)
     146            {
     147                xform = new AffineTransform();
     148                bounds = new Rectangle2D.Float();
     149                return;
     150            }
     151
     152            if (width == 0)
     153            {
     154                width = img.getWidth();
     155            }
     156            if (height == 0)
     157            {
     158                height = img.getHeight();
     159            }
     160
     161            //Determine image xform
    148162            xform = new AffineTransform();
    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());
    166 
     163            xform.translate(this.x, this.y);
     164            xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
     165        }
    167166        bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
    168167    }
     
    337336                URI src = sty.getURIValue(getXMLBase());
    338337
    339                 URL newVal;
     338                URL newVal = null;
    340339                if ("data".equals(src.getScheme()))
    341340                {
    342341                    newVal = new URL(null, src.toASCIIString(), new Handler());
    343                 } else
     342                } else if (!diagram.getUniverse().isImageDataInlineOnly())
    344343                {
    345344                    newVal = src.toURL();
    346345                }
    347346
    348                 if (!newVal.equals(imageSrc))
     347                if (newVal != null && !newVal.equals(imageSrc))
    349348                {
    350349                    imageSrc = newVal;
Note: See TracChangeset for help on using the changeset viewer.