Skip to content

Commit 41fe8c2

Browse files
committed
Move URL validation to StripePlugin
1 parent 53eca26 commit 41fe8c2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/Stripe Sdk/StripeSdkImpl.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,15 +391,16 @@ public class StripeSdkImpl: NSObject, UIAdaptivePresentationControllerDelegate {
391391
resolve(false)
392392
return;
393393
}
394-
guard let urlObj = URL(string: url) else {
394+
let urlObj = URL(string: url)
395+
if (urlObj == nil) {
395396
#if DEBUG
396397
print("[flutter_stripe] handleURLCallback called with invalid URL: \(url)")
397398
#endif
398399
resolve(false)
399400
return
400401
}
401402
DispatchQueue.main.async {
402-
let stripeHandled = StripeAPI.handleURLCallback(with: urlObj)
403+
let stripeHandled = StripeAPI.handleURLCallback(with: urlObj!)
403404
#if DEBUG
404405
if stripeHandled {
405406
print("[flutter_stripe] URL callback successfully handled by Stripe SDK: \(url)")

packages/stripe_ios/ios/stripe_ios/Sources/stripe_ios/StripePlugin.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ extension StripePlugin {
501501
result(FlutterError.init(code: ErrorType.Failed, message: "Invalid parametes", details: nil))
502502
return
503503
}
504+
505+
// Validate URL format before passing to StripeSdkImpl
506+
guard URL(string: url) != nil else {
507+
#if DEBUG
508+
print("[flutter_stripe] handleURLCallback called with invalid URL: \(url)")
509+
#endif
510+
result(false)
511+
return
512+
}
513+
504514
handleURLCallback(
505515
url: url,
506516
resolver: resolver(for: result),

0 commit comments

Comments
 (0)