From 7f23cdcc53eb96514e75ac13967e9db82151ce04 Mon Sep 17 00:00:00 2001 From: fuleyi Date: Tue, 16 Dec 2025 20:33:28 +0800 Subject: [PATCH] fix: handle nil URL parsing result for colon-containing filenames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix xdg-open unable to open files with colons in filename by adding nil check for URL parsing result. When parsing filenames containing colons, url.Parse may return nil URL object along with error, causing nil pointer dereference. The fix adds additional nil check to prevent crashes and fallback to file URI scheme detection. Influence: 1. Test opening files with colons in filename (e.g., "file:name.txt") 2. Verify normal file opening functionality remains unaffected 3. Test various special characters in filenames to ensure robustness 4. Check both local files and URLs to confirm proper scheme detection fix: 修复文件名中包含冒号时xdg-open无法打开的问题 添加对URL解析结果为nil的检查,防止空指针解引用。当解析包含冒号的文件名 时,url.Parse可能返回nil URL对象和错误,导致程序崩溃。修复后程序能正确回 退到文件URI方案检测。 Influence: 1. 测试打开文件名中包含冒号的文件(如"file:name.txt") 2. 验证正常文件打开功能不受影响 3. 测试文件名中包含各种特殊字符以确保鲁棒性 4. 检查本地文件和URL以确保正确的方案检测 --- dde-open/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dde-open/main.go b/dde-open/main.go index 27ef34b..f07a9a9 100644 --- a/dde-open/main.go +++ b/dde-open/main.go @@ -52,7 +52,7 @@ func main() { arg := flag.Arg(0) var scheme string u, err := url.Parse(arg) - if err != nil { + if err != nil || u == nil { gFile := gio.FileNewForCommandlineArg(arg) if gFile != nil { scheme = gFile.GetUriScheme()