Skip to content

Commit 0d0c714

Browse files
committed
Quote and prefix long paths when copying to clipboard
Paths copied to the clipboard are now quoted, and long paths (>= 260 characters) are prefixed with \\?\ to ensure compatibility. This improves reliability when handling long file paths.
1 parent 1aaf3cb commit 0d0c714

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Helper.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static Uri FilePathToFileUrl(string filePath)
4848
uri.Append('/');
4949
else
5050
uri.Append($"%{(int)v:X2}");
51-
if (uri.Length >= 2 && uri[0] == '/' && uri[1] == '/') // UNC path
51+
if (uri.Length >= 2 && uri[0] == '/' && uri[1] == '/') // UNC path - Universal Naming Convention
5252
uri.Insert(0, "file:");
5353
else
5454
uri.Insert(0, "file:///");

‎QuickLook/ViewerWindow.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ internal ViewerWindow()
115115
{
116116
try
117117
{
118-
Clipboard.SetText(_path);
118+
Clipboard.SetText($"\"{(_path.Length >= 260 ? @"\\?\" + _path : _path)}\"");
119119
Toast.Success(TranslationHelper.Get("InfoPanelMoreItem_CopySucc"));
120120
}
121121
catch (Exception e)

0 commit comments

Comments
 (0)