View Issue Details

IDProjectCategoryView StatusLast Update
0028659PackagesPackagespublic2016-11-27 20:01
Reporterwp Assigned ToFelipe Monteiro de Carvalho  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5 (SVN) 
Target Version1.6Fixed in Version1.6 
Summary0028659: fpvectorials svgreader crash
DescriptionAs discussed in the forum (http://forum.lazarus.freepascal.org/index.php/topic,29621.0.html) it seems to be within svg specification if no separating space or comma is placed before a negative number, e.g. using "15-15" instead of "15 -15" or "15,-15". I am not 100% sure about this statement, but Firefox definitely can read the "malformed" files appended to the forum discussion. The svgreader of fpvectorial, however, cannot. The tokenizer crashes when trying to convert these strings to numerical values.

The attached patch splits strings like "15-15" at the "-" character into its parts "15" and "-15" and makes these files readable by fpvectorial.

In tests with Firefox I saw that a "+" character can be used in the same way. Therefore, the patch handles this case as well.
Steps To ReproduceRun attached demo (which is adapted from the forum discussion).
Additional InformationFelipe, I could apply the fix by myself, but since I am not too familiar with fpvectorial I would like you to have a look at it. Please leave me a note if you want me to apply patches to fpvectorial by myself in the future. (BTW, there's a bunch of memory leaks).
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

wp

2015-09-10 21:37

developer  

svgvectorialreader.pas.patch (1,187 bytes)   
Index: components/fpvectorial/svgvectorialreader.pas
===================================================================
--- components/fpvectorial/svgvectorialreader.pas	(revision 49814)
+++ components/fpvectorial/svgvectorialreader.pas	(working copy)
@@ -275,12 +275,14 @@
 const
   Str_Space: Char = ' ';
   Str_Comma: Char = ',';
+  Str_Plus: Char = '+';
+  Str_Minus: Char = '-';
   ListOfCommandLetters: set of Char = ['a'..'d', 'f'..'z', 'A'..'D', 'F'..'Z'];
 var
   i: Integer;
   lTmpStr: string = '';
   lState: Integer;
-  lFirstTmpStrChar, lCurChar: Char;
+  lFirstTmpStrChar, lCurChar, lPrevChar: Char;
 begin
   lState := 0;
 
@@ -290,6 +292,7 @@
     case lState of
     0: // Adding to the tmp string
     begin
+      if i > 0 then lPrevChar := AStr[i-1];
       lCurChar := AStr[i];
       if lCurChar = Str_Space then
       begin
@@ -302,6 +305,11 @@
         AddToken(lTmpStr);
         lTmpStr := '';
       end
+      else if (lCurChar in [Str_Plus, Str_Minus]) and (lPrevChar in ['0'..'9']) then
+      begin
+        AddToken(lTmpStr);
+        lTmpStr := lCurChar;
+      end
       else
       begin
         // Check for a break, from letter to number
svgvectorialreader.pas.patch (1,187 bytes)   

wp

2015-09-10 21:39

developer  

TestSVG.zip (5,996 bytes)

Issue History

Date Modified Username Field Change
2015-09-10 21:37 wp New Issue
2015-09-10 21:37 wp Status new => assigned
2015-09-10 21:37 wp Assigned To => Felipe Monteiro de Carvalho
2015-09-10 21:37 wp File Added: svgvectorialreader.pas.patch
2015-09-10 21:39 wp File Added: TestSVG.zip
2015-09-10 21:41 wp Description Updated View Revisions
2015-09-10 21:41 wp Additional Information Updated View Revisions
2015-10-09 20:56 wp Status assigned => resolved
2015-10-09 20:56 wp Resolution open => fixed
2015-10-09 20:56 wp Status resolved => closed
2015-10-09 20:56 wp Status closed => assigned
2015-10-09 20:56 wp Resolution fixed => reopened
2015-10-09 20:56 wp Target Version 1.4.4 => 1.4.6
2015-10-09 20:57 wp Status assigned => closed
2015-10-09 20:57 wp Resolution reopened => fixed
2016-11-27 20:00 Bart Broersma Status closed => assigned
2016-11-27 20:00 Bart Broersma Resolution fixed => reopened
2016-11-27 20:00 Bart Broersma Target Version 1.4.6 => 1.6
2016-11-27 20:00 Bart Broersma Status assigned => resolved
2016-11-27 20:00 Bart Broersma Resolution reopened => fixed
2016-11-27 20:01 Bart Broersma Status resolved => closed
2016-11-27 20:01 Bart Broersma Fixed in Version => 1.6