Title: [154896] trunk
Revision
154896
Author
[email protected]
Date
2013-08-30 10:51:53 -0700 (Fri, 30 Aug 2013)

Log Message

SVG error parsing empty path
https://bugs.webkit.org/show_bug.cgi?id=78980

Reviewed by Darin Adler.

Source/WebCore:

According to the spec (http://www.w3.org/TR/SVG/paths.html#PathData), path 'd' attribute can be empty.
No error should be reported in this case.

* svg/SVGPathParser.cpp:
(WebCore::SVGPathParser::parsePathDataFromSource):
* svg/SVGPathUtilities.cpp:
(WebCore::buildPathFromString):
(WebCore::buildSVGPathByteStreamFromSVGPathSegList):
(WebCore::buildPathFromByteStream):
(WebCore::buildSVGPathSegListFromByteStream):
(WebCore::buildStringFromByteStream):
(WebCore::buildStringFromSVGPathSegList):
(WebCore::buildSVGPathByteStreamFromString):
(WebCore::buildAnimatedSVGPathByteStream):
(WebCore::addToSVGPathByteStream):

LayoutTests:

Adapt fuzz-path-parser.html and dynamic-empty-path.svg to also test empty paths.
Adjust expectations to not expect an error message for empty paths.

* platform/gtk/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
* platform/gtk/svg/custom/dynamic-empty-path-expected.txt:
* platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
* platform/qt/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
* platform/qt/svg/custom/dynamic-empty-path-expected.txt:
* svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
* svg/custom/dynamic-empty-path-expected.txt:
* svg/dom/fuzz-path-parser-expected.txt:
* svg/dom/fuzz-path-parser.html: also test empty path
* svg/dom/path-parser-expected.txt:
* svg/dom/script-tests/path-parser.js: also test empty path

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (154895 => 154896)


--- trunk/LayoutTests/ChangeLog	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/ChangeLog	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,3 +1,25 @@
+2013-08-30  Rob Buis  <[email protected]>
+
+        SVG error parsing empty path
+        https://bugs.webkit.org/show_bug.cgi?id=78980
+
+        Reviewed by Darin Adler.
+
+        Adapt fuzz-path-parser.html and dynamic-empty-path.svg to also test empty paths.
+        Adjust expectations to not expect an error message for empty paths.
+
+        * platform/gtk/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
+        * platform/gtk/svg/custom/dynamic-empty-path-expected.txt:
+        * platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
+        * platform/qt/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
+        * platform/qt/svg/custom/dynamic-empty-path-expected.txt:
+        * svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt:
+        * svg/custom/dynamic-empty-path-expected.txt:
+        * svg/dom/fuzz-path-parser-expected.txt:
+        * svg/dom/fuzz-path-parser.html: also test empty path
+        * svg/dom/path-parser-expected.txt:
+        * svg/dom/script-tests/path-parser.js: also test empty path
+
 2013-08-30  Arpita Bahuguna  <[email protected]>
 
         setAttributeNode() does not set the new value to an existing attribute if specified attribute is in a different case.

Modified: trunk/LayoutTests/platform/gtk/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt (154895 => 154896)


--- trunk/LayoutTests/platform/gtk/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/platform/gtk/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 267: Error: Problem parsing d=""
 layer at (0,0) size 480x360
   RenderView at (0,0) size 480x360
 layer at (0,0) size 480x360

Modified: trunk/LayoutTests/platform/gtk/svg/custom/dynamic-empty-path-expected.txt (154895 => 154896)


--- trunk/LayoutTests/platform/gtk/svg/custom/dynamic-empty-path-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/platform/gtk/svg/custom/dynamic-empty-path-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 9: Error: Problem parsing d=""
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 151x151

Modified: trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt (154895 => 154896)


--- trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 267: Error: Problem parsing d=""
 layer at (0,0) size 480x360
   RenderView at (0,0) size 480x360
 layer at (0,0) size 480x360

Modified: trunk/LayoutTests/platform/qt/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt (154895 => 154896)


--- trunk/LayoutTests/platform/qt/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/platform/qt/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 267: Error: Problem parsing d=""
 layer at (0,0) size 480x360
   RenderView at (0,0) size 480x360
 layer at (0,0) size 480x360

Modified: trunk/LayoutTests/platform/qt/svg/custom/dynamic-empty-path-expected.txt (154895 => 154896)


--- trunk/LayoutTests/platform/qt/svg/custom/dynamic-empty-path-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/platform/qt/svg/custom/dynamic-empty-path-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 9: Error: Problem parsing d=""
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 151x151

Modified: trunk/LayoutTests/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt (154895 => 154896)


--- trunk/LayoutTests/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 267: Error: Problem parsing d=""
 layer at (0,0) size 480x360
   RenderView at (0,0) size 480x360
 layer at (0,0) size 480x360

Modified: trunk/LayoutTests/svg/custom/dynamic-empty-path-expected.txt (154895 => 154896)


--- trunk/LayoutTests/svg/custom/dynamic-empty-path-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/svg/custom/dynamic-empty-path-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: line 9: Error: Problem parsing d=""
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 151x151

Modified: trunk/LayoutTests/svg/dom/fuzz-path-parser-expected.txt (154895 => 154896)


--- trunk/LayoutTests/svg/dom/fuzz-path-parser-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/svg/dom/fuzz-path-parser-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -198,7 +198,6 @@
 CONSOLE MESSAGE: Error: Problem parsing d="M1,1A3,6,9,7,2,7 7,c1 1 1,0 7,7,l1 6 zH0,Zs0 5 0 0 zL8 4 7,zA8,8 5,9 2,6 4,l2 2,L9 4,V"
 CONSOLE MESSAGE: Error: Problem parsing d="M1,1Q2 9,4 1,s6,3 6,9,s6 0,0,6,1 zc2,1 7 0,1 4,Z2 A3,4 5,4,6,8,2 ZV5 t2 6,v8,t9,1 V5 l9,5 s6,9,2 9,T1 9 "
 CONSOLE MESSAGE: Error: Problem parsing d="M1,1a9,2 6 1 2 2 2,za9 0 2 8,2,3,3 s5,8,8 1,HC5 8 5,8,4 2 c8 4 5 2 5 9,l3 9,H7 s6 2,0 0 a4 9,1 6,3,7,0,M6,"
-CONSOLE MESSAGE: Error: Problem parsing d=""
 CONSOLE MESSAGE: Error: Problem parsing d="M"
 CONSOLE MESSAGE: Error: Problem parsing d="M
 CONSOLE MESSAGE: Error: Problem parsing d="M1,1Z0"
@@ -458,6 +457,7 @@
 Parsed as 4 command(s) [MQss]: M1,1Q2 9,4 1,s6,3 6,9,s6 0,0,6,1 zc2,1 7 0,1 4,Z2 A3,4 5,4,6,8,2 ZV5 t2 6,v8,t9,1 V5 l9,5 s6,9,2 9,T1 9 
 Parsed as 1 command(s) [M]: M1,1a9,2 6 1 2 2 2,za9 0 2 8,2,3,3 s5,8,8 1,HC5 8 5,8,4 2 c8 4 5 2 5 9,l3 9,H7 s6 2,0 0 a4 9,1 6,3,7,0,M6,
 Could not parse: 
+Could not parse:  
 Could not parse: M
 Could not parse: M
 Parsed as 2 command(s) [MZ]: M1,1Z0

Modified: trunk/LayoutTests/svg/dom/fuzz-path-parser.html (154895 => 154896)


--- trunk/LayoutTests/svg/dom/fuzz-path-parser.html	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/svg/dom/fuzz-path-parser.html	2013-08-30 17:51:53 UTC (rev 154896)
@@ -86,6 +86,7 @@
         }
         // Empty-ish paths
         parsePath("");
+        parsePath(" ");
         parsePath("M");
         parsePath("M" + String.fromCharCode(0));
         // Edge case paths:

Modified: trunk/LayoutTests/svg/dom/path-parser-expected.txt (154895 => 154896)


--- trunk/LayoutTests/svg/dom/path-parser-expected.txt	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/svg/dom/path-parser-expected.txt	2013-08-30 17:51:53 UTC (rev 154896)
@@ -5,7 +5,6 @@
 CONSOLE MESSAGE: Error: Problem parsing d="M1,2"
 CONSOLE MESSAGE: Error: Problem parsing d="M1,2x"
 CONSOLE MESSAGE: Error: Problem parsing d="M1,2 L40,0#90"
-CONSOLE MESSAGE: Error: Problem parsing d=""
 CONSOLE MESSAGE: Error: Problem parsing d="x"
 CONSOLE MESSAGE: Error: Problem parsing d="L1,2"
 This tests the SVG path parser by parsing and then re-serializing various paths.
@@ -66,6 +65,7 @@
 PASS parsePath('M1,2x') is 'M1,2'
 PASS parsePath('M1,2 L40,0#90') is 'M1,2 L40,0'
 PASS parsePath('') is ''
+PASS parsePath(' ') is ''
 PASS parsePath('x') is ''
 PASS parsePath('L1,2') is ''
 PASS parsePath('M.1 .2 L.3 .4 .5 .6') is 'M0.1,0.2 L0.3,0.4 L0.5,0.6'

Modified: trunk/LayoutTests/svg/dom/script-tests/path-parser.js (154895 => 154896)


--- trunk/LayoutTests/svg/dom/script-tests/path-parser.js	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/LayoutTests/svg/dom/script-tests/path-parser.js	2013-08-30 17:51:53 UTC (rev 154896)
@@ -126,6 +126,7 @@
 shouldBe("parsePath('M1,2 L40,0#90')", "'M1,2 L40,0'");
 
 shouldBe("parsePath('')", "''");
+shouldBe("parsePath(' ')", "''");
 shouldBe("parsePath('x')", "''");
 shouldBe("parsePath('L1,2')", "''");
 shouldBe("parsePath('M.1 .2 L.3 .4 .5 .6')", "'M0.1,0.2 L0.3,0.4 L0.5,0.6'");

Modified: trunk/Source/WebCore/ChangeLog (154895 => 154896)


--- trunk/Source/WebCore/ChangeLog	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/Source/WebCore/ChangeLog	2013-08-30 17:51:53 UTC (rev 154896)
@@ -1,3 +1,26 @@
+2013-08-30  Rob Buis  <[email protected]>
+
+        SVG error parsing empty path
+        https://bugs.webkit.org/show_bug.cgi?id=78980
+
+        Reviewed by Darin Adler.
+
+        According to the spec (http://www.w3.org/TR/SVG/paths.html#PathData), path 'd' attribute can be empty.
+        No error should be reported in this case.
+
+        * svg/SVGPathParser.cpp:
+        (WebCore::SVGPathParser::parsePathDataFromSource):
+        * svg/SVGPathUtilities.cpp:
+        (WebCore::buildPathFromString):
+        (WebCore::buildSVGPathByteStreamFromSVGPathSegList):
+        (WebCore::buildPathFromByteStream):
+        (WebCore::buildSVGPathSegListFromByteStream):
+        (WebCore::buildStringFromByteStream):
+        (WebCore::buildStringFromSVGPathSegList):
+        (WebCore::buildSVGPathByteStreamFromString):
+        (WebCore::buildAnimatedSVGPathByteStream):
+        (WebCore::addToSVGPathByteStream):
+
 2013-08-30  Andreas Kling  <[email protected]>
 
         Try to fix CSS_VARIABLES and CSS_DEVICE_ADAPTATION builds.

Modified: trunk/Source/WebCore/svg/SVGPathParser.cpp (154895 => 154896)


--- trunk/Source/WebCore/svg/SVGPathParser.cpp	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/Source/WebCore/svg/SVGPathParser.cpp	2013-08-30 17:51:53 UTC (rev 154896)
@@ -297,7 +297,7 @@
 
     // Skip any leading spaces.
     if (!m_source->moveToNextToken())
-        return false;
+        return true;
 
     SVGPathSegType command;
     m_source->parseSVGSegmentType(command);

Modified: trunk/Source/WebCore/svg/SVGPathUtilities.cpp (154895 => 154896)


--- trunk/Source/WebCore/svg/SVGPathUtilities.cpp	2013-08-30 17:50:52 UTC (rev 154895)
+++ trunk/Source/WebCore/svg/SVGPathUtilities.cpp	2013-08-30 17:51:53 UTC (rev 154896)
@@ -113,7 +113,7 @@
 bool buildPathFromString(const String& d, Path& result)
 {
     if (d.isEmpty())
-        return false;
+        return true;
 
     SVGPathBuilder* builder = globalSVGPathBuilder(result);
 
@@ -129,7 +129,7 @@
     ASSERT(result);
     result->clear();
     if (list.isEmpty())
-        return false;
+        return true;
 
     SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result);
 
@@ -166,7 +166,7 @@
 {
     ASSERT(stream);
     if (stream->isEmpty())
-        return false;
+        return true;
 
     SVGPathBuilder* builder = globalSVGPathBuilder(result);
 
@@ -181,7 +181,7 @@
 {
     ASSERT(stream);
     if (stream->isEmpty())
-        return false; 
+        return true; 
 
     SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(element, parsingMode == NormalizedParsing ? PathSegNormalizedRole : PathSegUnalteredRole, result);
 
@@ -196,7 +196,7 @@
 {
     ASSERT(stream);
     if (stream->isEmpty())
-        return false; 
+        return true; 
 
     SVGPathStringBuilder* builder = globalSVGPathStringBuilder();
 
@@ -212,7 +212,7 @@
 {
     result = String();
     if (list.isEmpty())
-        return false;
+        return true;
 
     SVGPathStringBuilder* builder = globalSVGPathStringBuilder();
 
@@ -229,7 +229,7 @@
     ASSERT(result);
     result->clear();
     if (d.isEmpty())
-        return false;
+        return true;
 
     SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result);
 
@@ -249,7 +249,7 @@
 
     result->clear();
     if (toStream->isEmpty())
-        return false;
+        return true;
 
     SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result);
 
@@ -266,7 +266,7 @@
     ASSERT(fromStream);
     ASSERT(byStream);
     if (fromStream->isEmpty() || byStream->isEmpty())
-        return false;
+        return true;
 
     SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(fromStream);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to