This is an automated email from the ASF dual-hosted git repository.

NiklasMerz pushed a commit to branch 6.0.x
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git


The following commit(s) were added to refs/heads/6.0.x by this push:
     new 241d55a  fix(ios): check callbackId with regex
241d55a is described below

commit 241d55aa59b901c32cd3bf88725f1de656ebb0ec
Author: Niklas Merz <[email protected]>
AuthorDate: Wed May 20 22:17:56 2026 +0200

    fix(ios): check callbackId with regex
---
 src/ios/CDVWKInAppBrowser.m | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index a121fb1..54e5e4b 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -519,6 +519,18 @@ static CDVWKInAppBrowser* instance = nil;
     if([message.body isKindOfClass:[NSDictionary class]]){
         NSDictionary* messageContent = (NSDictionary*) message.body;
         NSString* scriptCallbackId = messageContent[@"id"];
+
+        // Only allow callback ids generated by this plugin, e.g. 
"InAppBrowser123".
+        if (![scriptCallbackId isKindOfClass:[NSString class]]) {
+            NSLog(@"InAppBrowser callback called with missing or non-string 
callback id");
+            return;
+        }
+
+        NSRegularExpression *callbackIdRegex = [NSRegularExpression 
regularExpressionWithPattern:@"^InAppBrowser[0-9]{1,10}$" options:0 error:nil];
+        if ([callbackIdRegex firstMatchInString:scriptCallbackId options:0 
range:NSMakeRange(0, scriptCallbackId.length)] == nil) {
+            NSLog(@"InAppBrowser callback called with invalid callbackId: %@", 
scriptCallbackId);
+            return;
+        }
         
         if([messageContent objectForKey:@"d"]){
             NSString* scriptResult = messageContent[@"d"];


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to