Title: [188085] trunk
Revision
188085
Author
commit-qu...@webkit.org
Date
2015-08-06 16:23:56 -0700 (Thu, 06 Aug 2015)

Log Message

Source/_javascript_Core:
The JSONP parser incorrectly parsers -0 as +0.
https://bugs.webkit.org/show_bug.cgi?id=147590

Patch by Keith Miller <keith_mil...@apple.com> on 2015-08-06
Reviewed by Michael Saboff.

In the LiteralParser we should use a double to store the accumulator for numerical tokens
rather than an int. Using an int means that -0 is, incorrectly, parsed as +0.

* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lexNumber):

LayoutTests:
The JSONP parser incorrectly parses -0 as +0.
https://bugs.webkit.org/show_bug.cgi?id=147590

Patch by Keith Miller <keith_mil...@apple.com> on 2015-08-06
Reviewed by Michael Saboff.

A simple test that attempts loads a JSONP that sets a variable to 0.

* js/regress/JSONP-negative-0-expected.txt: Added.
* js/regress/JSONP-negative-0.html: Added.
* js/regress/script-tests/JSONP-negative-0.js: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (188084 => 188085)


--- trunk/LayoutTests/ChangeLog	2015-08-06 23:22:43 UTC (rev 188084)
+++ trunk/LayoutTests/ChangeLog	2015-08-06 23:23:56 UTC (rev 188085)
@@ -1,3 +1,16 @@
+2015-08-06  Keith Miller  <keith_mil...@apple.com>
+
+        The JSONP parser incorrectly parses -0 as +0.
+        https://bugs.webkit.org/show_bug.cgi?id=147590
+
+        Reviewed by Michael Saboff.
+
+        A simple test that attempts loads a JSONP that sets a variable to 0.
+
+        * js/regress/JSONP-negative-0-expected.txt: Added.
+        * js/regress/JSONP-negative-0.html: Added.
+        * js/regress/script-tests/JSONP-negative-0.js: Added.
+
 2015-08-06  Chris Dumez  <cdu...@apple.com>
 
         Toggle GPS state based on page visibility to save battery

Added: trunk/LayoutTests/js/regress/JSONP-negative-0-expected.txt (0 => 188085)


--- trunk/LayoutTests/js/regress/JSONP-negative-0-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/regress/JSONP-negative-0-expected.txt	2015-08-06 23:23:56 UTC (rev 188085)
@@ -0,0 +1,11 @@
+JSRegress/JSONP-negative-0
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Object.is(-0,x) is true
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/regress/JSONP-negative-0.html (0 => 188085)


--- trunk/LayoutTests/js/regress/JSONP-negative-0.html	                        (rev 0)
+++ trunk/LayoutTests/js/regress/JSONP-negative-0.html	2015-08-06 23:23:56 UTC (rev 188085)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script>
+shouldBeTrue("Object.is(-0,x)");
+</script>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/js/regress/script-tests/JSONP-negative-0.js (0 => 188085)


--- trunk/LayoutTests/js/regress/script-tests/JSONP-negative-0.js	                        (rev 0)
+++ trunk/LayoutTests/js/regress/script-tests/JSONP-negative-0.js	2015-08-06 23:23:56 UTC (rev 188085)
@@ -0,0 +1 @@
+x = -0

Modified: trunk/Source/_javascript_Core/ChangeLog (188084 => 188085)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-06 23:22:43 UTC (rev 188084)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-06 23:23:56 UTC (rev 188085)
@@ -1,3 +1,16 @@
+2015-08-06  Keith Miller  <keith_mil...@apple.com>
+
+        The JSONP parser incorrectly parsers -0 as +0.
+        https://bugs.webkit.org/show_bug.cgi?id=147590
+
+        Reviewed by Michael Saboff.
+
+        In the LiteralParser we should use a double to store the accumulator for numerical tokens
+        rather than an int. Using an int means that -0 is, incorrectly, parsed as +0.
+
+        * runtime/LiteralParser.cpp:
+        (JSC::LiteralParser<CharType>::Lexer::lexNumber):
+
 2015-08-06  Filip Pizlo  <fpi...@apple.com>
 
         Structures used for tryGetConstantProperty() should be registered first

Modified: trunk/Source/_javascript_Core/runtime/LiteralParser.cpp (188084 => 188085)


--- trunk/Source/_javascript_Core/runtime/LiteralParser.cpp	2015-08-06 23:22:43 UTC (rev 188084)
+++ trunk/Source/_javascript_Core/runtime/LiteralParser.cpp	2015-08-06 23:23:56 UTC (rev 188085)
@@ -497,7 +497,7 @@
         while (m_ptr < m_end && isASCIIDigit(*m_ptr))
             ++m_ptr;
     } else if (m_ptr < m_end && (*m_ptr != 'e' && *m_ptr != 'E') && (m_ptr - token.start) < 10) {
-        int result = 0;
+        double result = 0;
         token.type = TokNumber;
         token.end = m_ptr;
         const CharType* digit = token.start;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to