Fix +[ProtocolClient escapedFilePathURI:] to not double-escape.
authorRobert Sesek <rsesek@bluestatic.org>
Thu, 19 May 2022 04:51:26 +0000 (00:51 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Thu, 19 May 2022 04:52:58 +0000 (00:52 -0400)
CHANGES.md
Source/ProtocolClient.m

index 70c7649bea959e25331b4a1336c31cbaf69bbc3e..d0ec07b00b283f0b27b245ab6678076e4ddda620 100644 (file)
@@ -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
index 99baa7eeb4572c2981ffef068c8b64a1616cb930..f9d6fb8f7391e99c3ba4ef94711b38592fc9c586 100644 (file)
 }
 
 + (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 ////////////////////////////////////////////////////////