From 0d0c71407cc2089dea42e79b990f01a67c8821f2 Mon Sep 17 00:00:00 2001 From: ema Date: Mon, 6 Oct 2025 15:50:25 +0800 Subject: [PATCH] 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. --- QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Helper.cs | 2 +- QuickLook/ViewerWindow.xaml.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Helper.cs b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Helper.cs index bc0ec94..89cdea3 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Helper.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Helper.cs @@ -48,7 +48,7 @@ internal static class Helper uri.Append('/'); else uri.Append($"%{(int)v:X2}"); - if (uri.Length >= 2 && uri[0] == '/' && uri[1] == '/') // UNC path + if (uri.Length >= 2 && uri[0] == '/' && uri[1] == '/') // UNC path - Universal Naming Convention uri.Insert(0, "file:"); else uri.Insert(0, "file:///"); diff --git a/QuickLook/ViewerWindow.xaml.cs b/QuickLook/ViewerWindow.xaml.cs index 3636246..46b63b6 100644 --- a/QuickLook/ViewerWindow.xaml.cs +++ b/QuickLook/ViewerWindow.xaml.cs @@ -115,7 +115,7 @@ public partial class ViewerWindow : Window { try { - Clipboard.SetText(_path); + Clipboard.SetText($"\"{(_path.Length >= 260 ? @"\\?\" + _path : _path)}\""); Toast.Success(TranslationHelper.Get("InfoPanelMoreItem_CopySucc")); } catch (Exception e)