From be1adcf576fdd4d552f7c6be82a440b71eb3dcfb Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 19 May 2022 00:51:26 -0400 Subject: [PATCH] Fix +[ProtocolClient escapedFilePathURI:] to not double-escape. --- CHANGES.md | 6 ++++++ Source/ProtocolClient.m | 18 +++--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 70c7649..d0ec07b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ MacGDBp CHANGE LOG ================================================================================ +2.1.2 +--------------------- +- Fix: #267 Do not improperly double-escape file paths that contain %-encoded + characters (e.g. spaces). + + 2.1.1 --------------------- - Fix: Constrain the minimum size of the debugger split views, so that panes diff --git a/Source/ProtocolClient.m b/Source/ProtocolClient.m index 99baa7e..f9d6fb8 100644 --- a/Source/ProtocolClient.m +++ b/Source/ProtocolClient.m @@ -119,22 +119,10 @@ } + (NSString*)escapedFilePathURI:(NSString*)path { - // Custon GDBp paths are fine. - if ([[path substringToIndex:4] isEqualToString:@"gdbp"]) + // The backend will interpret this custom scheme. + if ([path hasPrefix:@"gdbp://"]) return path; - - // Create a temporary URL that will escape all the nasty characters. - NSURL* url = [NSURL fileURLWithPath:path]; - NSString* urlString = [url absoluteString]; - - // Remove the host because this is a file:// URL; - NSString* host = [url host]; - if (host) - urlString = [urlString stringByReplacingOccurrencesOfString:[url host] withString:@""]; - - // Escape % for use in printf-style NSString formatters. - urlString = [urlString stringByReplacingOccurrencesOfString:@"%" withString:@"%%"]; - return urlString; + return [[NSURL fileURLWithPath:path] absoluteString]; } // MessageQueueDelegate //////////////////////////////////////////////////////// -- 2.43.5