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
ec7a1d83
Commit
ec7a1d83
authored
Nov 13, 2015
by
Robert Marki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix character skipping after a surrogate pair
In a string the first character following a surrogate pair is skipped by the lexer, but the rest of the string is parsed as usual.
parent
39486303
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
4 deletions
+9
-4
json.hpp
src/json.hpp
+2
-2
json.hpp.re2c
src/json.hpp.re2c
+2
-2
unit.cpp
test/unit.cpp
+5
-0
No files found.
src/json.hpp
View file @
ec7a1d83
...
@@ -6856,8 +6856,8 @@ basic_json_parser_59:
...
@@ -6856,8 +6856,8 @@ basic_json_parser_59:
auto
codepoint2
=
std
::
strtoul
(
std
::
string
(
reinterpret_cast
<
typename
string_t
::
const_pointer
>
auto
codepoint2
=
std
::
strtoul
(
std
::
string
(
reinterpret_cast
<
typename
string_t
::
const_pointer
>
(
i
+
7
),
4
).
c_str
(),
nullptr
,
16
);
(
i
+
7
),
4
).
c_str
(),
nullptr
,
16
);
result
+=
to_unicode
(
codepoint
,
codepoint2
);
result
+=
to_unicode
(
codepoint
,
codepoint2
);
// skip the next 1
1
characters (xxxx\uyyyy)
// skip the next 1
0
characters (xxxx\uyyyy)
i
+=
1
1
;
i
+=
1
0
;
}
}
else
else
{
{
...
...
src/json.hpp.re2c
View file @
ec7a1d83
...
@@ -6162,8 +6162,8 @@ class basic_json
...
@@ -6162,8 +6162,8 @@ class basic_json
auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
auto codepoint2 = std::strtoul(std::string(reinterpret_cast<typename string_t::const_pointer>
(i + 7), 4).c_str(), nullptr, 16);
(i + 7), 4).c_str(), nullptr, 16);
result += to_unicode(codepoint, codepoint2);
result += to_unicode(codepoint, codepoint2);
// skip the next 1
1
characters (xxxx\uyyyy)
// skip the next 1
0
characters (xxxx\uyyyy)
i += 1
1
;
i += 1
0
;
}
}
else
else
{
{
...
...
test/unit.cpp
View file @
ec7a1d83
...
@@ -10205,4 +10205,9 @@ TEST_CASE("regression tests")
...
@@ -10205,4 +10205,9 @@ TEST_CASE("regression tests")
j
[
"string"
]
=
bytes
;
j
[
"string"
]
=
bytes
;
CHECK
(
j
[
"string"
]
==
"\u0007\u0007"
);
CHECK
(
j
[
"string"
]
==
"\u0007\u0007"
);
}
}
SECTION
(
"character following a surrogate pair is skipped"
)
{
CHECK
(
json
::
parse
(
"
\"\\
ud80c
\\
udc60abc
\"
"
).
get
<
json
::
string_t
>
()
==
u8"\U00013060abc"
);
}
}
}
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