Skip to content

Commit

Permalink
wip: restrict external urls
Browse files Browse the repository at this point in the history
  • Loading branch information
rajveermalviya committed Jan 7, 2025
1 parent 467725f commit b27be87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import UserNotifications
)
}

// Allow only `zulip://login` external urls.
override func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if url.scheme == "zulip" && url.host == "login" {
return super.application(application, open: url, options: options)
}
return false
}

// Handle notification tap while the app is running.
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ZulipApp extends StatefulWidget {
class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
@override
Future<bool> didPushRouteInformation(routeInformation) async {
print("didPushRouteInformation: ${routeInformation.uri}");
switch (routeInformation.uri) {
case Uri(scheme: 'zulip', host: 'login') && var url:
await LoginPage.handleWebAuthUrl(url);
Expand Down Expand Up @@ -206,7 +207,8 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
// like [Navigator.push], never mere names as with [Navigator.pushNamed].
onGenerateRoute: (_) => null,

onGenerateInitialRoutes: (_) {
onGenerateInitialRoutes: (String initialRoute) {
print("onGenerateInitialRoutes: $initialRoute");
return [
if (initialAccountId == null)
MaterialWidgetRoute(page: const ChooseAccountPage())
Expand Down

0 comments on commit b27be87

Please sign in to comment.