encoding/jsonpb: fix parsing of number strings containing leading/trailing spaces

Per conformance tests, number strings that contain leading or trailing
spaces are not allowed.

https://github.com/protocolbuffers/protobuf/blob/3a3956e8a258784461270961c6577341356bce52/conformance/binary_json_conformance_suite.cc#L1196-L1203

Change-Id: Ifbe0e4ee125fac3c291b456eece541353025cdd4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/173664
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/encoding/jsonpb/decode_test.go b/encoding/jsonpb/decode_test.go
index 9fb95d6..6226b07 100644
--- a/encoding/jsonpb/decode_test.go
+++ b/encoding/jsonpb/decode_test.go
@@ -253,6 +253,16 @@
 			SDouble: math.Inf(-1),
 		},
 	}, {
+		desc:         "float string with leading space",
+		inputMessage: &pb3.Scalars{},
+		inputText:    `{"sFloat": " 1.234"}`,
+		wantErr:      true,
+	}, {
+		desc:         "double string with trailing space",
+		inputMessage: &pb3.Scalars{},
+		inputText:    `{"sDouble": "5.678 "}`,
+		wantErr:      true,
+	}, {
 		desc:         "not float",
 		inputMessage: &pb3.Scalars{},
 		inputText:    `{"sFloat": true}`,
@@ -324,6 +334,16 @@
 			SInt32: 12,
 		},
 	}, {
+		desc:         "integer string with leading space",
+		inputMessage: &pb3.Scalars{},
+		inputText:    `{"sInt32": " 1234"}`,
+		wantErr:      true,
+	}, {
+		desc:         "integer string with trailing space",
+		inputMessage: &pb3.Scalars{},
+		inputText:    `{"sUint32": "1e2 "}`,
+		wantErr:      true,
+	}, {
 		desc:         "number is not an integer",
 		inputMessage: &pb3.Scalars{},
 		inputText:    `{"sInt32": 1.001}`,