diff options
author | Marc Butler <mockbutler@gmail.com> | 2020-03-13 06:10:30 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 12:10:30 -0700 |
commit | 0e3fdd0eeac998974179fd48874a2d98dbf9af83 (patch) | |
tree | 6de77eae5f782a665a4c580c9a8e4539cdfdc6b6 /src/idl_gen_json_schema.cpp | |
parent | 45a2b07cbd83c14c233bafd0f7d850bc52f9aa24 (diff) | |
download | flatbuffers-0e3fdd0eeac998974179fd48874a2d98dbf9af83.tar.gz flatbuffers-0e3fdd0eeac998974179fd48874a2d98dbf9af83.tar.bz2 flatbuffers-0e3fdd0eeac998974179fd48874a2d98dbf9af83.zip |
Escape characters in jsonschema descriptions (#5644)
* Escape JSON Schema comments
* Add quotes to monster comment
Thus exercising the JSON Schema comment escape support.
Diffstat (limited to 'src/idl_gen_json_schema.cpp')
-rw-r--r-- | src/idl_gen_json_schema.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/idl_gen_json_schema.cpp b/src/idl_gen_json_schema.cpp index ecdb587b..a1d0704d 100644 --- a/src/idl_gen_json_schema.cpp +++ b/src/idl_gen_json_schema.cpp @@ -155,7 +155,12 @@ class JsonSchemaGenerator : public BaseGenerator { comment.append(*comment_line); } if (comment.size() > 0) { - code_ += " \"description\" : \"" + comment + "\","; + std::string description; + if (!EscapeString(comment.c_str(), comment.length(), &description, true, + true)) { + return false; + } + code_ += " \"description\" : " + description + ","; } code_ += " \"properties\" : {"; |