Skip to content

Commit b23fd7f

Browse files
committed
fix: handle nil URL parsing result for colon-containing filenames
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以确保正确的方案检测
1 parent a4c9423 commit b23fd7f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dde-open/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func main() {
5252
arg := flag.Arg(0)
5353
var scheme string
5454
u, err := url.Parse(arg)
55-
if err != nil {
55+
if err != nil || u == nil {
5656
gFile := gio.FileNewForCommandlineArg(arg)
5757
if gFile != nil {
5858
scheme = gFile.GetUriScheme()

0 commit comments

Comments
 (0)