GUACAMOLE-1215: Merge correction for escaping of backslashes in JSON strings.

This commit is contained in:
Mike Jumper 2021-05-17 12:25:23 -07:00 committed by GitHub
commit 44145f681a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,15 +97,15 @@ int guac_common_json_write_string(guac_user* user,
const char* current = str; const char* current = str;
for (; *current != '\0'; current++) { for (; *current != '\0'; current++) {
/* Escape all quotes */ /* Escape all quotes and back-slashes */
if (*current == '"') { if (*current == '"' || *current == '\\') {
/* Write any string content up to current character */ /* Write any string content up to current character */
if (current != str) if (current != str)
blob_written |= guac_common_json_write(user, stream, blob_written |= guac_common_json_write(user, stream,
json_state, str, current - str); json_state, str, current - str);
/* Escape the quote that was just read */ /* Escape the character that was just read */
blob_written |= guac_common_json_write(user, stream, blob_written |= guac_common_json_write(user, stream,
json_state, "\\", 1); json_state, "\\", 1);