Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2587)

Unified Diff: base/json/string_escape.cc

Issue 2903773003: Escape invalid code points (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/json/string_escape_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/string_escape.cc
diff --git a/base/json/string_escape.cc b/base/json/string_escape.cc
index f67fa93bf2648191564eb1a77d46664036b1f41d..1ba1210ad4708a6b948e5fc8b3745669b346fe21 100644
--- a/base/json/string_escape.cc
+++ b/base/json/string_escape.cc
@@ -91,7 +91,8 @@ bool EscapeJSONStringImpl(const S& str, bool put_in_quotes, std::string* dest) {
for (int32_t i = 0; i < length; ++i) {
uint32_t code_point;
- if (!ReadUnicodeCharacter(str.data(), length, &i, &code_point)) {
+ if (!ReadUnicodeCharacter(str.data(), length, &i, &code_point) ||
+ code_point < 0 || !IsValidCharacter(code_point)) {
Mark Mentovai 2017/05/24 19:02:48 How can code_point, a uint32_t, ever be < 0?
Mark Mentovai 2017/05/24 19:02:48 More importantly, you’re confusing characters with
sabbakumov 2017/05/25 03:26:14 I've updated the documentation. IsValidCharacter()
sabbakumov 2017/05/25 03:26:14 Thank you. I've mistakenly copy-pasted it from her
sabbakumov 2017/05/25 03:26:14 Done.
sabbakumov 2017/05/25 03:26:14 Done.
code_point = kReplacementCodePoint;
did_replacement = true;
}
« no previous file with comments | « no previous file | base/json/string_escape_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698