Bug 1272781 - nsEscape should work with ns(C)Strings and not with char pointers, r=smaug

This commit is contained in:
Andrea Marchesini
2016-05-18 18:21:56 +02:00
parent 9943149ec1
commit 794c728c57
9 changed files with 54 additions and 76 deletions

View File

@@ -5230,24 +5230,21 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
// Create a URL to pass all the error information through to the page.
#undef SAFE_ESCAPE
#define SAFE_ESCAPE(cstring, escArg1, escArg2) \
{ \
char* s = nsEscape(escArg1, escArg2); \
if (!s) \
return NS_ERROR_OUT_OF_MEMORY; \
cstring.Adopt(s); \
#define SAFE_ESCAPE(output, input, params) \
if (NS_WARN_IF(!NS_Escape(input, output, params))) { \
return NS_ERROR_OUT_OF_MEMORY; \
}
nsCString escapedUrl, escapedCharset, escapedError, escapedDescription,
escapedCSSClass;
SAFE_ESCAPE(escapedUrl, url.get(), url_Path);
SAFE_ESCAPE(escapedCharset, charset.get(), url_Path);
SAFE_ESCAPE(escapedError,
NS_ConvertUTF16toUTF8(aErrorType).get(), url_Path);
SAFE_ESCAPE(escapedUrl, url, url_Path);
SAFE_ESCAPE(escapedCharset, charset, url_Path);
SAFE_ESCAPE(escapedError, NS_ConvertUTF16toUTF8(aErrorType), url_Path);
SAFE_ESCAPE(escapedDescription,
NS_ConvertUTF16toUTF8(aDescription).get(), url_Path);
NS_ConvertUTF16toUTF8(aDescription), url_Path);
if (aCSSClass) {
SAFE_ESCAPE(escapedCSSClass, aCSSClass, url_Path);
nsCString cssClass(aCSSClass);
SAFE_ESCAPE(escapedCSSClass, cssClass, url_Path);
}
nsCString errorPageUrl("about:");
errorPageUrl.AppendASCII(aErrorPage);
@@ -5276,9 +5273,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
nsresult rv = GetAppManifestURL(manifestURL);
if (manifestURL.Length() > 0) {
nsCString manifestParam;
SAFE_ESCAPE(manifestParam,
NS_ConvertUTF16toUTF8(manifestURL).get(),
url_Path);
SAFE_ESCAPE(manifestParam, NS_ConvertUTF16toUTF8(manifestURL), url_Path);
errorPageUrl.AppendLiteral("&m=");
errorPageUrl.AppendASCII(manifestParam.get());
}