summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAGaliuzov <AGaliuzov@luxoft.com>2016-06-22 08:17:30 -0700
committerGitHub <noreply@github.com>2016-06-22 08:17:30 -0700
commit0843cf4323fe0c177fb9b211357c6c35112e1147 (patch)
treeae1ad2548770323636432182276d089360e593c6
parent715276fcde63620894da3b5c629d8eaa5d5cd5c3 (diff)
parent0a0d488e62cf76064ea970af6cf7ee2c93a03b7a (diff)
downloadsdl_core-0843cf4323fe0c177fb9b211357c6c35112e1147.tar.gz
Merge pull request #583 from smartdevicelink/hotfix/add_escape_characters_during_ptu_header_construction
Parse PT String for HTTP Request Body
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h1
-rw-r--r--src/components/application_manager/src/commands/mobile/on_system_request_notification.cc20
2 files changed, 19 insertions, 2 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h
index 78b41159ff..0763e680a8 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h
@@ -72,6 +72,7 @@ class OnSystemRequestNotification : public CommandNotificationImpl {
* @param message Message
*/
void AddHeader(BinaryMessage& message) const;
+ void ParsePTString(std::string& pt_string) const;
#endif
DISALLOW_COPY_AND_ASSIGN(OnSystemRequestNotification);
diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
index 90ec18d3b1..fbcbaede81 100644
--- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
@@ -116,7 +116,8 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
if (0 > sprintf(timeout_str, "%d", timeout)) {
memset(timeout_str, 0, sizeof(timeout_str));
}
-
+ std::string policy_table_string = std::string(message.begin(), message.end());
+ ParsePTString(policy_table_string);
const std::string header =
"{"
@@ -133,7 +134,7 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
"\"charset\": \"utf-8\","
"\"Content_Length\": " + std::string(size_str) +
"},"
- "\"body\": \"" + std::string(message.begin(), message.end()) + "\""
+ "\"body\": \"" + policy_table_string + "\""
"}"
"}";
@@ -143,6 +144,21 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
LOG4CXX_DEBUG(
logger_, "Header added: " << std::string(message.begin(), message.end()));
}
+
+void OnSystemRequestNotification::ParsePTString(std::string& pt_string) const{
+ std::string result;
+ size_t length = pt_string.length();
+ result.reserve(length*2);
+ for(size_t i=0;i<length;++i){
+ if(pt_string[i]=='\"' || pt_string[i]=='\\'){
+ result += '\\';
+ } else if(pt_string[i] == '\n') {
+ continue;
+ }
+ result += pt_string[i];
+ }
+ pt_string = result;
+}
#endif
} //namespace mobile