Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
4e3d0f5b
Commit
4e3d0f5b
authored
Mar 01, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix parsing of value with comma
Closes gh-12297
parent
c2f7dd86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
BasicJsonParser.java
...n/java/org/springframework/boot/json/BasicJsonParser.java
+5
-1
AbstractJsonParserTests.java
...rg/springframework/boot/json/AbstractJsonParserTests.java
+8
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/json/BasicJsonParser.java
View file @
4e3d0f5b
...
...
@@ -124,6 +124,7 @@ public class BasicJsonParser implements JsonParser {
int
index
=
0
;
int
inObject
=
0
;
int
inList
=
0
;
boolean
inValue
=
false
;
StringBuilder
build
=
new
StringBuilder
();
while
(
index
<
json
.
length
())
{
char
current
=
json
.
charAt
(
index
);
...
...
@@ -139,7 +140,10 @@ public class BasicJsonParser implements JsonParser {
if
(
current
==
']'
)
{
inList
--;
}
if
(
current
==
','
&&
inObject
==
0
&&
inList
==
0
)
{
if
(
current
==
'"'
)
{
inValue
=
!
inValue
;
}
if
(
current
==
','
&&
inObject
==
0
&&
inList
==
0
&&
!
inValue
)
{
list
.
add
(
build
.
toString
());
build
.
setLength
(
0
);
}
...
...
spring-boot/src/test/java/org/springframework/boot/json/AbstractJsonParserTests.java
View file @
4e3d0f5b
...
...
@@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dave Syer
* @author Jean de Klerk
* @author Stephane Nicoll
*/
public
abstract
class
AbstractJsonParserTests
{
...
...
@@ -63,6 +64,13 @@ public abstract class AbstractJsonParserTests {
assertThat
(
map
.
get
(
"foo"
)).
isEqualTo
(
"123"
);
}
@Test
public
void
stringContainingComma
()
{
Map
<
String
,
Object
>
map
=
this
.
parser
.
parseMap
(
"{\"foo\":\"bar1,bar2\"}"
);
assertThat
(
map
).
hasSize
(
1
);
assertThat
(
map
.
get
(
"foo"
)).
isEqualTo
(
"bar1,bar2"
);
}
@Test
public
void
emptyMap
()
{
Map
<
String
,
Object
>
map
=
this
.
parser
.
parseMap
(
"{}"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment