From 608aae69a1b1c9e5dd7d59e65e38088e615281df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Thu, 14 Feb 2008 22:53:34 +0000 Subject: [PATCH] * make sure an url mime type is registered before using it. * lines and cols are 1-based. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23959 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/open.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/bin/open.cpp b/src/bin/open.cpp index 3d782bf08c..2672d04ffa 100644 --- a/src/bin/open.cpp +++ b/src/bin/open.cpp @@ -85,15 +85,17 @@ main(int argc, char **argv) // try to open it as an URI BString mimeType = "application/x-vnd.Be.URL."; BString arg(*argv); - if (arg.FindFirst("://") >= 0) - mimeType.Append(arg, arg.FindFirst("://")); - else - mimeType.Append(arg, arg.FindFirst(":")); + mimeType.Append(arg, arg.FindFirst(":")); - char *args[2] = { *argv, NULL }; - status = be_roster->Launch(openWith ? openWith : mimeType.String(), 1, args); - if (status == B_OK) - continue; + // the protocol should be alphanum + // we just check if it's registered + // if not there is likely no supporting app anyway + if (BMimeType::IsValid(mimeType.String())) { + char *args[2] = { *argv, NULL }; + status = be_roster->Launch(openWith ? openWith : mimeType.String(), 1, args); + if (status == B_OK) + continue; + } // maybe it's "file:line" or "file:line:col" int line = 0, col = 0, i; @@ -109,7 +111,7 @@ main(int argc, char **argv) status = entry.SetTo(arg.String()); if (status == B_OK && entry.Exists()) - status = open_file(openWith, entry, line - 1, col - 1); + status = open_file(openWith, entry, line); if (status == B_OK) continue; @@ -121,7 +123,7 @@ main(int argc, char **argv) status = entry.SetTo(arg.String()); if (status == B_OK && entry.Exists()) - status = open_file(openWith, entry, line - 1, col - 1); + status = open_file(openWith, entry, line, col); } } else status = B_ENTRY_NOT_FOUND;