Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Source/AppAuthCore/OIDAuthorizationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,20 @@ - (void)cancelWithCompletion:(nullable void (^)(void))completion {
+ (BOOL)URL:(NSURL *)URL matchesRedirectionURL:(NSURL *)redirectionURL {
NSURL *standardizedURL = [URL standardizedURL];
NSURL *standardizedRedirectURL = [redirectionURL standardizedURL];
// An empty path may be represented as '' or '/'. In order to treat these two cases as equivalent,
// we normalize a path of '/' to ''.
// For context: https://github.com/openid/AppAuth-iOS/issues/446
NSString *normalizedPath = [standardizedURL.path isEqualToString:@"/"] ? @""
: standardizedURL.path;
NSString *normalizedRedirectPath = [standardizedRedirectURL.path isEqualToString:@"/"] ? @""
: standardizedRedirectURL.path;

return [standardizedURL.scheme caseInsensitiveCompare:standardizedRedirectURL.scheme] == NSOrderedSame
&& OIDIsEqualIncludingNil(standardizedURL.user, standardizedRedirectURL.user)
&& OIDIsEqualIncludingNil(standardizedURL.password, standardizedRedirectURL.password)
&& OIDIsEqualIncludingNil(standardizedURL.host, standardizedRedirectURL.host)
&& OIDIsEqualIncludingNil(standardizedURL.port, standardizedRedirectURL.port)
&& OIDIsEqualIncludingNil(standardizedURL.path, standardizedRedirectURL.path);
&& OIDIsEqualIncludingNil(normalizedPath, normalizedRedirectPath);
}

- (BOOL)shouldHandleURL:(NSURL *)URL {
Expand Down