Skip to content

Commit

Permalink
Merge branch 'fix-cve' of https://github.com/don-vip/svgSalamander in…
Browse files Browse the repository at this point in the history
…to don-vip-fix-cve
  • Loading branch information
blackears committed Oct 21, 2018
2 parents 8616cfd + 826555b commit aabc840
Showing 1 changed file with 35 additions and 41 deletions.
76 changes: 35 additions & 41 deletions svg-core/src/main/java/com/kitfox/svg/ImageSVG.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,21 @@ protected void build() throws SVGException
{
if (getPres(sty.setName("xlink:href")))
{


URI src = sty.getURIValue(getXMLBase());
if ("data".equals(src.getScheme()))
{
imageSrc = new URL(null, src.toASCIIString(), new Handler());
}
else
else if (!diagram.getUniverse().isImageDataInlineOnly())
{

if (!diagram.getUniverse().isImageDataInlineOnly())
try
{
try
{
imageSrc = src.toURL();
} catch (Exception e)
{
Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
"Could not parse xlink:href " + src, e);
// e.printStackTrace();
imageSrc = null;
}
imageSrc = src.toURL();
} catch (Exception e)
{
Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
"Could not parse xlink:href " + src, e);
imageSrc = null;
}
}
}
Expand All @@ -143,32 +136,33 @@ protected void build() throws SVGException
throw new SVGException(e);
}

diagram.getUniverse().registerImage(imageSrc);

//Set widths if not set
BufferedImage img = diagram.getUniverse().getImage(imageSrc);
if (img == null)
if (imageSrc != null)
{
xform = new AffineTransform();
bounds = new Rectangle2D.Float();
return;
}
diagram.getUniverse().registerImage(imageSrc);

if (width == 0)
{
width = img.getWidth();
}
if (height == 0)
{
height = img.getHeight();
}
//Set widths if not set
BufferedImage img = diagram.getUniverse().getImage(imageSrc);
if (img == null)
{
xform = new AffineTransform();
bounds = new Rectangle2D.Float();
return;
}

if (width == 0)
{
width = img.getWidth();
}
if (height == 0)
{
height = img.getHeight();
}

//Determine image xform
xform = new AffineTransform();
// xform.setToScale(this.width / img.getWidth(), this.height / img.getHeight());
// xform.translate(this.x, this.y);
xform.translate(this.x, this.y);
xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
//Determine image xform
xform = new AffineTransform();
xform.translate(this.x, this.y);
xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
}

bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
}
Expand Down Expand Up @@ -342,16 +336,16 @@ public boolean updateTime(double curTime) throws SVGException
{
URI src = sty.getURIValue(getXMLBase());

URL newVal;
URL newVal = null;
if ("data".equals(src.getScheme()))
{
newVal = new URL(null, src.toASCIIString(), new Handler());
} else
} else if (!diagram.getUniverse().isImageDataInlineOnly())
{
newVal = src.toURL();
}

if (!newVal.equals(imageSrc))
if (newVal != null && !newVal.equals(imageSrc))
{
imageSrc = newVal;
shapeChange = true;
Expand Down

0 comments on commit aabc840

Please sign in to comment.