Repository: struts
Updated Branches:
  refs/heads/master 30fd44f0e -> 3480bc3c1


fix for WW-4269

blank double results in NumberFormatException being thrown on sending
JSON in request body

Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/db483ccd
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/db483ccd
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/db483ccd

Branch: refs/heads/master
Commit: db483ccd153caa97137f00cb4ff2ebd35143d56e
Parents: 30fd44f
Author: Victor Sosa <[email protected]>
Authored: Wed Dec 30 13:36:58 2015 -0400
Committer: Victor Sosa <[email protected]>
Committed: Wed Dec 30 13:36:58 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/struts2/json/JSONReader.java     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/db483ccd/plugins/json/src/main/java/org/apache/struts2/json/JSONReader.java
----------------------------------------------------------------------
diff --git a/plugins/json/src/main/java/org/apache/struts2/json/JSONReader.java 
b/plugins/json/src/main/java/org/apache/struts2/json/JSONReader.java
index 3f8c175..75abb19 100644
--- a/plugins/json/src/main/java/org/apache/struts2/json/JSONReader.java
+++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONReader.java
@@ -155,6 +155,7 @@ public class JSONReader {
         return new JSONException("Input string is not well formed JSON 
(invalid char " + this.c + ")");
     }
 
+    
     @SuppressWarnings("unchecked")
     protected List array() throws JSONException {
         List ret = new ArrayList();
@@ -174,7 +175,7 @@ public class JSONReader {
         return ret;
     }
 
-    protected Object number() {
+    protected Object number() throws JSONException {
         this.buf.setLength(0);
         boolean toDouble = false;
 
@@ -202,9 +203,17 @@ public class JSONReader {
         }
 
         if (toDouble) {
-            return Double.parseDouble(this.buf.toString());
+            try {
+                return Double.parseDouble(this.buf.toString());
+            } catch (NumberFormatException e) {
+                throw buildInvalidInputException();
+            }
         } else {
-            return Long.parseLong(this.buf.toString());
+            try {
+                return Long.parseLong(this.buf.toString());
+            } catch (NumberFormatException e) {
+                throw buildInvalidInputException();
+            }
         }
     }
 

Reply via email to