Skip to content

Commit b56bd0b

Browse files
committed
Fixed some missing escaping of parameters when sent as JSON
1 parent c4479a5 commit b56bd0b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

WebViewJavascriptBridge/WebViewJavascriptBridge.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ - (void)_dispatchMessage:(NSDictionary *)message {
8989
#else
9090
NSString *messageJSON = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:message options:0 error:nil] encoding:NSUTF8StringEncoding];
9191
#endif
92+
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\\\" withString:@"\\\\\\\\"];
9293
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\n" withString:@"\\\\n"];
94+
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\\r" withString:@"\\\\r"];
9395
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
9496
messageJSON = [messageJSON stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
9597
[_webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"WebViewJavascriptBridge._handleMessageFromObjC('%@');", messageJSON]];

0 commit comments

Comments
 (0)