diff --git a/CHANGES.rst b/CHANGES.rst index c81e55ade..d435db2aa 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,7 @@ Changes to be released in next version 🐛 Bugfix * Push: Fix PushKit crashes due to undecryptable call invites (#3986). * matrix.to: Cannot open links with query parameters (#3990). + * matrix.to: Cannot open/preview a new room given by alias (#3991). ⚠️ API Changes * diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 3fb7de7d4..ba0e306cc 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -1380,9 +1380,27 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni withString:[MXTools encodeURIComponent:roomId] ]; - universalLinkFragmentPendingRoomAlias = @{roomId: roomIdOrAlias}; + // The previous operation can fail because of percent encoding + // TBH we are not clean on data inputs. For the moment, just give another try with no encoding + // TODO: Have a dedicated module and tests to handle universal links (matrix.to, email link, etc) + if ([newUniversalLinkFragment isEqualToString:fragment]) + { + newUniversalLinkFragment = + [fragment stringByReplacingOccurrencesOfString:roomIdOrAlias + withString:[MXTools encodeURIComponent:roomId]]; + } - [self handleUniversalLinkFragment:newUniversalLinkFragment]; + if (![newUniversalLinkFragment isEqualToString:fragment]) + { + universalLinkFragmentPendingRoomAlias = @{roomId: roomIdOrAlias}; + + [self handleUniversalLinkFragment:newUniversalLinkFragment]; + } + else + { + // Do not continue. Else we will loop forever + NSLog(@"[AppDelegate] Universal link: Error: Cannot resolve alias in %@ to the room id %@", fragment, roomId); + } } } failure:^(NSError *error) {