diff options
author | Shobhit Adlakha <ShobhitAd@users.noreply.github.com> | 2022-05-27 10:15:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 10:15:34 -0400 |
commit | 2fa821028d2457a4e9d62381edb635769b8bf704 (patch) | |
tree | 78b378a3386dd0f8979b82bb99ee30654c99f204 | |
parent | 65947fd1eb30a392948d67003df0fe803c070c6b (diff) | |
download | sdl_core-2fa821028d2457a4e9d62381edb635769b8bf704.tar.gz |
Fix/Adjust PTS content length for newline string (#3913)
* Add check for newline string and adjust content length for added escape character
* Apply same fix to sample_policy_manager for extern proprietary
* Address review comments
-rw-r--r-- | src/appMain/sample_policy_manager.py | 7 | ||||
-rw-r--r-- | src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/appMain/sample_policy_manager.py b/src/appMain/sample_policy_manager.py index 75a04685ed..2b3f835c57 100644 --- a/src/appMain/sample_policy_manager.py +++ b/src/appMain/sample_policy_manager.py @@ -25,12 +25,17 @@ parser.add_argument("--encryption", action="store_true", def http_header(data): +# The Content-Length to be sent in the HTTP Request header should be +# adjusted for additional escape characters added for newline strings +# The mobile proxy will remove the escape characters after receiving this request. + content_length = len(data) - data.count('\\') + header = {} header["HTTPRequest"] = {} header["HTTPRequest"]["headers"] = { "ConnectTimeout": 60, "ContentType": "application/json", - "Content-Length": len(data), + "Content-Length": content_length, "DoInput": True, "DoOutput": True, "InstanceFollowRedirects": False, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index af0a5a6539..0537043cd4 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -225,8 +225,13 @@ size_t OnSystemRequestNotification::ParsePTString( size_t result_length = length; result.reserve(length * 2); for (size_t i = 0; i < length; ++i) { - if (pt_string[i] == '\"' || pt_string[i] == '\\') { + if (pt_string[i] == '\"') { result += '\\'; + } else if (pt_string[i] == '\\') { + result += '\\'; + --result_length; // contentLength is adjusted for the additional escape + // character added before special characters (like the + // newline string) } else if (pt_string[i] == '\n') { --result_length; // contentLength is adjusted when this character is // not copied to result. |