From ad7574be598eb1d18f9ec667b7b7a0d6a893d381 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 29 Jun 2022 19:39:13 -0700 Subject: [PATCH] [Sandbox] Fix URL fragment removal function This should be deleting from the #, including the #. Signed-off-by: Christopher Snowhill --- Utils/SandboxBroker.m | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Utils/SandboxBroker.m b/Utils/SandboxBroker.m index eed972d6b..62aaae9c7 100644 --- a/Utils/SandboxBroker.m +++ b/Utils/SandboxBroker.m @@ -107,17 +107,12 @@ static SandboxBroker *kSharedSandboxBroker = nil; NSString *s = [url path]; - NSString *lastComponent = [url fragment]; - - if(lastComponent) { - lastComponent = @"#"; - // Find that last component in the string from the end to make sure - // to get the last one - NSRange fragmentRange = [s rangeOfString:lastComponent - options:NSBackwardsSearch]; + NSRange fragmentRange = [s rangeOfString:@"#" + options:NSBackwardsSearch]; + if(fragmentRange.location != NSNotFound) { // Chop the fragment. - NSString *newURLString = [s substringToIndex:fragmentRange.location + fragmentRange.length]; + NSString *newURLString = [s substringToIndex:fragmentRange.location]; return [NSURL fileURLWithPath:newURLString]; } else {