Skip to content

Commit e070577

Browse files
authored
Merge pull request #138 from calvium/quote_in_message_causes_failure
iOS: Escape singlequotes or messages containing ' will fail
2 parents 9fa9654 + 5072390 commit e070577

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ios/RCTWebViewBridge.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ - (void)sendToBridge:(NSString *)message
9898
}
9999
}());
100100
);
101+
102+
// Escape singlequotes or messages containing ' will fail
103+
NSString *quotedMessage = [message stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
101104

102-
NSString *command = [NSString stringWithFormat: format, message];
105+
NSString *command = [NSString stringWithFormat: format, quotedMessage];
103106
[_webView stringByEvaluatingJavaScriptFromString:command];
104107
}
105108

0 commit comments

Comments
 (0)