]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Fri, 3 Aug 2018 11:20:50 +0000 (07:20 -0400)
committerCristy <urban-warrior@imagemagick.org>
Fri, 3 Aug 2018 11:20:50 +0000 (07:20 -0400)
coders/svg.c

index 2332f59d12da26799e1caf5526f1813f0b5f44fa..62dcd94085062818a9bfbdea1cd8fdfbaf9a9784 100644 (file)
@@ -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