From 04d0dcd1ae92eb71cd6d82c5a3604dd05bb9cfd9 Mon Sep 17 00:00:00 2001 From: "locka%iol.ie" Date: Wed, 14 Nov 2001 13:26:43 +0000 Subject: [PATCH] Add error message when user tries to load a malformed url instead of silently ignoring it. b=89118 r=ccarlen@netscape.com sr=rpotts@netscape.com git-svn-id: svn://10.0.0.236/trunk@108052 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/appstrings.properties | 1 + mozilla/docshell/base/nsDocShell.cpp | 23 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mozilla/docshell/base/appstrings.properties b/mozilla/docshell/base/appstrings.properties index fec46f2a7d1..c98c172915c 100644 --- a/mozilla/docshell/base/appstrings.properties +++ b/mozilla/docshell/base/appstrings.properties @@ -17,6 +17,7 @@ # # Contributor(s): +malformedURI=The URL is not valid and cannot be loaded. fileNotFound=The file %s cannot be found. Please check the location and try again. dnsNotFound=%s could not be found. Please check the name and try again. protocolNotFound=%s is not a registered protocol. diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index fd5be156c11..7d061800505 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2206,8 +2206,9 @@ nsDocShell::LoadURI(const PRUnichar * aURI, PRUint32 aLoadFlags) nsXPIDLString messageStr; NS_ENSURE_SUCCESS(stringBundle-> - GetStringFromName(NS_LITERAL_STRING("protocolNotFound").get(), - getter_Copies(messageStr)), + GetStringFromName( + NS_LITERAL_STRING("protocolNotFound").get(), + getter_Copies(messageStr)), NS_ERROR_FAILURE); nsAutoString uriString(aURI); @@ -2225,6 +2226,24 @@ nsDocShell::LoadURI(const PRUnichar * aURI, PRUint32 aLoadFlags) prompter->Alert(nsnull, msg); nsTextFormatter::smprintf_free(msg); } // end unknown protocol + else if (NS_ERROR_MALFORMED_URI == rv) { + // malformed URI + nsCOMPtr prompter; + nsCOMPtr stringBundle; + GetPromptAndStringBundle(getter_AddRefs(prompter), + getter_AddRefs(stringBundle)); + + NS_ENSURE_TRUE(stringBundle, NS_ERROR_FAILURE); + + nsXPIDLString messageStr; + NS_ENSURE_SUCCESS(stringBundle-> + GetStringFromName( + NS_LITERAL_STRING("malformedURI").get(), + getter_Copies(messageStr)), + NS_ERROR_FAILURE); + + prompter->Alert(nsnull, messageStr.get()); + } if (!uri) return NS_ERROR_FAILURE;