Skip to content

Commit 5072390

Browse files
committed
Escape singlequotes or messages containing ' will fail
1 parent d446ef1 commit 5072390

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
@@ -97,8 +97,11 @@ - (void)sendToBridge:(NSString *)message
9797
}
9898
}());
9999
);
100+
101+
// Escape singlequotes or messages containing ' will fail
102+
NSString *quotedMessage = [message stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
100103

101-
NSString *command = [NSString stringWithFormat: format, message];
104+
NSString *command = [NSString stringWithFormat: format, quotedMessage];
102105
[_webView stringByEvaluatingJavaScriptFromString:command];
103106
}
104107

0 commit comments

Comments
 (0)