Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
2ba554e4
Commit
2ba554e4
authored
Jun 05, 2017
by
HenryLee
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into issue550
parents
f2e16430
1a9d7667
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
7 deletions
+30
-7
src/json.hpp
src/json.hpp
+9
-3
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+8
-0
test/src/unit-unicode.cpp
test/src/unit-unicode.cpp
+13
-4
No files found.
src/json.hpp
View file @
2ba554e4
...
@@ -6381,7 +6381,7 @@ class basic_json
...
@@ -6381,7 +6381,7 @@ class basic_json
{
{
case
value_t
:
:
array
:
case
value_t
:
:
array
:
{
{
return
*
lhs
.
m_value
.
array
<
*
rhs
.
m_value
.
array
;
return
(
*
lhs
.
m_value
.
array
)
<
(
*
rhs
.
m_value
.
array
)
;
}
}
case
value_t
:
:
object
:
case
value_t
:
:
object
:
{
{
...
@@ -8799,7 +8799,7 @@ class basic_json
...
@@ -8799,7 +8799,7 @@ class basic_json
// store number of bytes in the buffer
// store number of bytes in the buffer
fill_size
=
static_cast
<
size_t
>
(
is
.
gcount
());
fill_size
=
static_cast
<
size_t
>
(
is
.
gcount
());
// skip byte
-
order mark
// skip byte
order mark
if
(
fill_size
>=
3
and
buffer
[
0
]
==
'\xEF'
and
buffer
[
1
]
==
'\xBB'
and
buffer
[
2
]
==
'\xBF'
)
if
(
fill_size
>=
3
and
buffer
[
0
]
==
'\xEF'
and
buffer
[
1
]
==
'\xBB'
and
buffer
[
2
]
==
'\xBF'
)
{
{
buffer_pos
+=
3
;
buffer_pos
+=
3
;
...
@@ -8896,7 +8896,13 @@ class basic_json
...
@@ -8896,7 +8896,13 @@ class basic_json
public:
public:
input_buffer_adapter
(
const
char
*
b
,
size_t
l
)
input_buffer_adapter
(
const
char
*
b
,
size_t
l
)
:
input_adapter
(),
cursor
(
b
),
limit
(
b
+
l
),
start
(
b
)
:
input_adapter
(),
cursor
(
b
),
limit
(
b
+
l
),
start
(
b
)
{}
{
// skip byte order mark
if
(
l
>=
3
and
b
[
0
]
==
'\xEF'
and
b
[
1
]
==
'\xBB'
and
b
[
2
]
==
'\xBF'
)
{
cursor
+=
3
;
}
}
// delete because of pointer members
// delete because of pointer members
input_buffer_adapter
(
const
input_buffer_adapter
&
)
=
delete
;
input_buffer_adapter
(
const
input_buffer_adapter
&
)
=
delete
;
...
...
test/src/unit-regression.cpp
View file @
2ba554e4
...
@@ -711,6 +711,7 @@ TEST_CASE("regression tests")
...
@@ -711,6 +711,7 @@ TEST_CASE("regression tests")
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input"
);
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input"
);
}
}
/*
SECTION("second example from #529")
SECTION("second example from #529")
{
{
std::string str = "{\n\"one\" : 1,\n\"two\" : 2\n}\n{\n\"three\" : 3\n}";
std::string str = "{\n\"one\" : 1,\n\"two\" : 2\n}\n{\n\"three\" : 3\n}";
...
@@ -748,6 +749,7 @@ TEST_CASE("regression tests")
...
@@ -748,6 +749,7 @@ TEST_CASE("regression tests")
std::remove("test.json");
std::remove("test.json");
}
}
*/
}
}
SECTION
(
"issue #389 - Integer-overflow (OSS-Fuzz issue 267)"
)
SECTION
(
"issue #389 - Integer-overflow (OSS-Fuzz issue 267)"
)
...
@@ -1167,4 +1169,10 @@ TEST_CASE("regression tests")
...
@@ -1167,4 +1169,10 @@ TEST_CASE("regression tests")
std
::
vector
<
uint8_t
>
vec
=
{
'"'
,
'\\'
,
'"'
,
'X'
,
'"'
,
'"'
};
std
::
vector
<
uint8_t
>
vec
=
{
'"'
,
'\\'
,
'"'
,
'X'
,
'"'
,
'"'
};
CHECK_THROWS_AS
(
json
::
parse
(
vec
),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
vec
),
json
::
parse_error
);
}
}
SECTION
(
"issue #602 - BOM not skipped when using json:parse(iterator)"
)
{
std
::
string
i
=
"
\xef\xbb\xbf
{
\n
\"
foo
\"
: true
\n
}"
;
CHECK_NOTHROW
(
json
::
parse
(
i
.
begin
(),
i
.
end
()));
}
}
}
test/src/unit-unicode.cpp
View file @
2ba554e4
...
@@ -1012,10 +1012,19 @@ TEST_CASE("Unicode", "[hide]")
...
@@ -1012,10 +1012,19 @@ TEST_CASE("Unicode", "[hide]")
SECTION
(
"ignore byte-order-mark"
)
SECTION
(
"ignore byte-order-mark"
)
{
{
// read a file with a UTF-8 BOM
SECTION
(
"in a stream"
)
std
::
ifstream
f
(
"test/data/json_nlohmann_tests/bom.json"
);
{
json
j
;
// read a file with a UTF-8 BOM
CHECK_NOTHROW
(
f
>>
j
);
std
::
ifstream
f
(
"test/data/json_nlohmann_tests/bom.json"
);
json
j
;
CHECK_NOTHROW
(
f
>>
j
);
}
SECTION
(
"with an iterator"
)
{
std
::
string
i
=
"
\xef\xbb\xbf
{
\n
\"
foo
\"
: true
\n
}"
;
CHECK_NOTHROW
(
json
::
parse
(
i
.
begin
(),
i
.
end
()));
}
}
}
SECTION
(
"error for incomplete/wrong BOM"
)
SECTION
(
"error for incomplete/wrong BOM"
)
...
...
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