Sfoglia il codice sorgente

Issue 2330 – Hang when opening path with duplicated backslash

Source commit: 1d5b18f47310ae92b95e830916e35c95d63ccf7b
Martin Prikryl 10 mesi fa
parent
commit
ba59faac9b
1 ha cambiato i file con 13 aggiunte e 1 eliminazioni
  1. 13 1
      source/packages/filemng/DirView.pas

+ 13 - 1
source/packages/filemng/DirView.pas

@@ -821,12 +821,24 @@ const
   LongPathPrefix = '\\?\';
 var
   LongPath: string;
-  Len: Integer;
+  P, Len: Integer;
 begin
   // do checks before passing directory to drive view, because
   // it would truncate non-existing directory to first superior existing
   Value := ReplaceStr(Value, '/', '\');
 
+  // Particularly the TDriveView.FindPathNode (its ExtractFileDir) cannot handle double backslashes
+  while True do
+  begin
+    P := Value.LastIndexOf('\\'); // 0-based
+    if P <= 0 then // not found or UNC
+        Break
+      else
+    begin
+      System.Delete(Value, P + 1, 1);
+    end;
+  end;
+
   // GetLongPathName would resolve to it the current working directory
   if (Length(Value) = 2) and CharInSet(UpperCase(Value)[1], ['A'..'Z']) and (Value[2] = ':') then
   begin