From a64a7bcf238a071cedea3fcdf585ec0e94d992bd Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 3 Aug 2018 07:20:50 -0400 Subject: [PATCH] ... --- coders/svg.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/coders/svg.c b/coders/svg.c index 2332f59d1..62dcd9408 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -553,7 +553,7 @@ static void SVGElementDeclaration(void *context,const xmlChar *name,int type, name,(xmlElementTypeVal) type,content); } -static void SVGStripString(char *message) +static void SVGStripString(const MagickBooleanType trim,char *message) { register char *p, @@ -583,23 +583,26 @@ static void SVGStripString(char *message) *q++=(*p); } *q='\0'; - /* - Remove whitespace. - */ - length=strlen(message); - p=message; - while (isspace((int) ((unsigned char) *p)) != 0) - p++; - if ((*p == '\'') || (*p == '"')) - p++; - q=message+length-1; - while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p)) - q--; - if (q > p) - if ((*q == '\'') || (*q == '"')) - q--; - (void) memmove(message,p,(size_t) (q-p+1)); - message[q-p+1]='\0'; + if (trim != MagickFalse) + { + /* + Remove whitespace. + */ + length=strlen(message); + p=message; + while (isspace((int) ((unsigned char) *p)) != 0) + p++; + if ((*p == '\'') || (*p == '"')) + p++; + q=message+length-1; + while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p)) + q--; + if (q > p) + if ((*q == '\'') || (*q == '"')) + q--; + (void) memmove(message,p,(size_t) (q-p+1)); + message[q-p+1]='\0'; + } /* Convert newlines to a space. */ @@ -661,13 +664,13 @@ static char **SVGKeyValuePairs(void *context,const int key_sentinel, } tokens[i]=AcquireString(p); (void) CopyMagickString(tokens[i],p,(size_t) (q-p+1)); - SVGStripString(tokens[i]); + SVGStripString(MagickTrue,tokens[i]); i++; p=q+1; } tokens[i]=AcquireString(p); (void) CopyMagickString(tokens[i],p,(size_t) (q-p+1)); - SVGStripString(tokens[i++]); + SVGStripString(MagickTrue,tokens[i++]); tokens[i]=(char *) NULL; *number_tokens=(size_t) i; return(tokens); @@ -2792,7 +2795,7 @@ static void SVGCharacters(void *context,const xmlChar *c,int length) for (i=0; i < (ssize_t) length; i++) *p++=c[i]; *p='\0'; - SVGStripString(text); + SVGStripString(MagickFalse,text); if (svg_info->text == (char *) NULL) svg_info->text=text; else -- 2.50.1