From 2a8426d8bb4c13e637df19db232a7336c14fef8f Mon Sep 17 00:00:00 2001 From: "bsmedberg%covad.net" Date: Tue, 18 Jan 2005 13:09:08 +0000 Subject: [PATCH] Bug 276588 followup: fix absolute URIs of the form "firefox http://www.tld.com/" which regressed at some point during the review process. There was a reason for all that hacky code. r=glazou sr=bustage-fix git-svn-id: svn://10.0.0.236/trunk@167942 18797224-902f-48f8-a5cc-f745e15eee43 --- .../commandlines/src/nsCommandLine.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mozilla/toolkit/components/commandlines/src/nsCommandLine.cpp b/mozilla/toolkit/components/commandlines/src/nsCommandLine.cpp index 6cd056fdb9c..44a8b6fda27 100644 --- a/mozilla/toolkit/components/commandlines/src/nsCommandLine.cpp +++ b/mozilla/toolkit/components/commandlines/src/nsCommandLine.cpp @@ -389,18 +389,28 @@ nsCommandLine::ResolveURI(const nsAString& aArgument, nsIURI* *aResult) nsCOMPtr io = do_GetIOService(); NS_ENSURE_TRUE(io, NS_ERROR_OUT_OF_MEMORY); - // First, pretend it's a file - nsCOMPtr file; - rv = ResolveFile(aArgument, getter_AddRefs(file)); - if (NS_SUCCEEDED(rv)) { - return io->NewFileURI(file, aResult); + NS_ConvertUTF16toUTF8 cargument(aArgument); + + // If there appears to be a URI scheme at the beginning of the argument, + // it is not a file arg, don't even try. + + nsCAutoString scheme; + rv = io->ExtractScheme(cargument, scheme); + + if (NS_FAILED(rv)) { + // pretend it's an absolute file path + nsCOMPtr file; + rv = ResolveFile(aArgument, getter_AddRefs(file)); + if (NS_SUCCEEDED(rv)) { + return io->NewFileURI(file, aResult); + } } nsCOMPtr workingDirURI; rv = io->NewFileURI(mWorkingDir, getter_AddRefs(workingDirURI)); NS_ENSURE_SUCCESS(rv, rv); - return io->NewURI(NS_ConvertUTF16toUTF8(aArgument), + return io->NewURI(cargument, nsnull, workingDirURI, aResult);