You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/10/17 03:41:54 UTC
ios commit: CB-7643 - made isValidCallbackId threadsafe
Repository: cordova-ios
Updated Branches:
refs/heads/master 24e3ba6c0 -> 9a3b1085f
CB-7643 - made isValidCallbackId threadsafe
_callbackIdPattern was being changed on multiple threads which caused bad access errors
Signed-off-by: Shazron Abdullah <sh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9a3b1085
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9a3b1085
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9a3b1085
Branch: refs/heads/master
Commit: 9a3b1085f22956d463d9a5732f3316214a4a1005
Parents: 24e3ba6
Author: samedii <sa...@gmail.com>
Authored: Fri Sep 26 00:49:08 2014 +0200
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Oct 16 18:40:58 2014 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVCommandDelegateImpl.m | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9a3b1085/CordovaLib/Classes/CDVCommandDelegateImpl.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegateImpl.m b/CordovaLib/Classes/CDVCommandDelegateImpl.m
index 76f5ef4..fc3346d 100644
--- a/CordovaLib/Classes/CDVCommandDelegateImpl.m
+++ b/CordovaLib/Classes/CDVCommandDelegateImpl.m
@@ -31,7 +31,14 @@
if (self != nil) {
_viewController = viewController;
_commandQueue = _viewController.commandQueue;
- _callbackIdPattern = nil;
+
+ NSError* err = nil;
+ _callbackIdPattern = [NSRegularExpression regularExpressionWithPattern:@"[^A-Za-z0-9._-]" options:0 error:&err];
+ if (err != nil) {
+ // Couldn't initialize Regex
+ NSLog(@"Error: Couldn't initialize regex");
+ _callbackIdPattern = nil;
+ }
}
return self;
}
@@ -97,21 +104,11 @@
- (BOOL)isValidCallbackId:(NSString*)callbackId
{
- NSError* err = nil;
-
- if (callbackId == nil) {
+
+ if (callbackId == nil || _callbackIdPattern == nil) {
return NO;
}
- // Initialize on first use
- if (_callbackIdPattern == nil) {
- // Catch any invalid characters in the callback id.
- _callbackIdPattern = [NSRegularExpression regularExpressionWithPattern:@"[^A-Za-z0-9._-]" options:0 error:&err];
- if (err != nil) {
- // Couldn't initialize Regex; No is safer than Yes.
- return NO;
- }
- }
// Disallow if too long or if any invalid characters were found.
if (([callbackId length] > 100) || [_callbackIdPattern firstMatchInString:callbackId options:0 range:NSMakeRange(0, [callbackId length])]) {
return NO;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org