Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
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
Chen Yisong
json
Commits
a8136c57
Commit
a8136c57
authored
Oct 29, 2016
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed BOM handling #344
parent
b820bb3b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
6 deletions
+10
-6
json.hpp
src/json.hpp
+0
-0
json.hpp.re2c
src/json.hpp.re2c
+8
-4
unit-unicode.cpp
test/src/unit-unicode.cpp
+2
-2
No files found.
src/json.hpp
View file @
a8136c57
This diff is collapsed.
Click to expand it.
src/json.hpp.re2c
View file @
a8136c57
...
@@ -7620,6 +7620,14 @@ class basic_json
...
@@ -7620,6 +7620,14 @@ class basic_json
{
{
// fill buffer
// fill buffer
fill_line_buffer();
fill_line_buffer();
// skip UTF-8 byte-order mark
if (m_line_buffer.size() >= 3 and m_line_buffer.substr(0, 3) == "\xEF\xBB\xBF")
{
m_line_buffer[0] = ' ';
m_line_buffer[1] = ' ';
m_line_buffer[2] = ' ';
}
}
}
// switch off unwanted functions (due to pointer members)
// switch off unwanted functions (due to pointer members)
...
@@ -7802,10 +7810,6 @@ class basic_json
...
@@ -7802,10 +7810,6 @@ class basic_json
ws = [ \t\n\r]+;
ws = [ \t\n\r]+;
ws { continue; }
ws { continue; }
// ignore byte-order-mark
bom = "\xEF\xBB\xBF";
bom { continue; }
// structural characters
// structural characters
"[" { last_token_type = token_type::begin_array; break; }
"[" { last_token_type = token_type::begin_array; break; }
"]" { last_token_type = token_type::end_array; break; }
"]" { last_token_type = token_type::end_array; break; }
...
...
test/src/unit-unicode.cpp
View file @
a8136c57
...
@@ -159,7 +159,7 @@ TEST_CASE("Unicode", "[hide]")
...
@@ -159,7 +159,7 @@ TEST_CASE("Unicode", "[hide]")
}
}
}
}
}
}
/*
SECTION
(
"ignore byte-order-mark"
)
SECTION
(
"ignore byte-order-mark"
)
{
{
// read a file with a UTF-8 BOM
// read a file with a UTF-8 BOM
...
@@ -167,7 +167,7 @@ TEST_CASE("Unicode", "[hide]")
...
@@ -167,7 +167,7 @@ TEST_CASE("Unicode", "[hide]")
json
j
;
json
j
;
CHECK_NOTHROW
(
j
<<
f
);
CHECK_NOTHROW
(
j
<<
f
);
}
}
*/
SECTION
(
"error for incomplete/wrong BOM"
)
SECTION
(
"error for incomplete/wrong BOM"
)
{
{
CHECK_THROWS_AS
(
json
::
parse
(
"
\xef\xbb
"
),
std
::
invalid_argument
);
CHECK_THROWS_AS
(
json
::
parse
(
"
\xef\xbb
"
),
std
::
invalid_argument
);
...
...
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