Skip to content

Commit f63c78b

Browse files
committed
Properly escape strings when creating an MVG file in the internal SVG decoder (GHSA-xpg8-7m6m-jf56)
1 parent fe0a49a commit f63c78b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

coders/svg.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,6 +2659,9 @@ static void SVGEndElement(void *context,const xmlChar *name)
26592659
{
26602660
if (LocaleCompare((const char *) name,"image") == 0)
26612661
{
2662+
char
2663+
*text;
2664+
26622665
Image
26632666
*image;
26642667

@@ -2686,12 +2689,13 @@ static void SVGEndElement(void *context,const xmlChar *name)
26862689
image_info=DestroyImageInfo(image_info);
26872690
if (image != (Image *) NULL)
26882691
image=DestroyImage(image);
2689-
26902692
(void) DeleteNodeFromSplayTree(svg_tree,svg_info->url);
2693+
text=EscapeString(svg_info->url,'\"');
26912694
(void) FormatLocaleFile(svg_info->file,
26922695
"image Over %g,%g %g,%g \"%s\"\n",svg_info->bounds.x,
26932696
svg_info->bounds.y,svg_info->bounds.width,svg_info->bounds.height,
2694-
svg_info->url);
2697+
text);
2698+
text=DestroyString(text);
26952699
(void) FormatLocaleFile(svg_info->file,"pop graphic-context\n");
26962700
break;
26972701
}
@@ -2904,11 +2908,15 @@ static void SVGEndElement(void *context,const xmlChar *name)
29042908
{
29052909
if (LocaleCompare((char *) name,"use") == 0)
29062910
{
2911+
char
2912+
*text;
2913+
29072914
if ((svg_info->bounds.x != 0.0) || (svg_info->bounds.y != 0.0))
29082915
(void) FormatLocaleFile(svg_info->file,"translate %g,%g\n",
29092916
svg_info->bounds.x,svg_info->bounds.y);
2910-
(void) FormatLocaleFile(svg_info->file,"use \"url(%s)\"\n",
2911-
svg_info->url);
2917+
text=EscapeString(svg_info->url,'\"');
2918+
(void) FormatLocaleFile(svg_info->file,"use \"url(%s)\"\n",text);
2919+
text=DestroyString(text);
29122920
(void) FormatLocaleFile(svg_info->file,"pop graphic-context\n");
29132921
break;
29142922
}

0 commit comments

Comments
 (0)