From 8a51623b1541da856aff2e4f00dc99693e5c2371 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Tue, 25 Apr 2006 16:49:47 +0000 Subject: [PATCH] Make the results of javascript: URLs stay UTF-16 rather than removing the high byte of the characters, and set the encoding on the channel to UTF-16. b=335298 r=darin sr=brendan git-svn-id: svn://10.0.0.236/trunk@195360 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp index 6b238fe3cd0..99b7498937b 100644 --- a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -294,9 +294,9 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel) rv = NS_ERROR_DOM_RETVAL_UNDEFINED; } else { - // NS_NewStringInputStream calls ToNewCString - // XXXbe this should not decimate! pass back UCS-2 to necko - rv = NS_NewStringInputStream(getter_AddRefs(mInnerStream), result); + rv = NS_NewByteInputStream(getter_AddRefs(mInnerStream), + NS_REINTERPRET_CAST(const char*, result.get()), + result.Length() * sizeof(PRUnichar), NS_ASSIGNMENT_COPY); } return rv; } @@ -402,8 +402,16 @@ nsresult nsJSChannel::Init(nsIURI *aURI) // If the resultant script evaluation actually does return a value, we // treat it as html. + NS_NAMED_LITERAL_CSTRING(contentType, "text/html"); + // Use ifdefs so things won't compile if the macros aren't set up right. +#ifdef IS_LITTLE_ENDIAN + NS_NAMED_LITERAL_CSTRING(contentCharset, "UTF-16LE"); +#endif +#ifdef IS_BIG_ENDIAN + NS_NAMED_LITERAL_CSTRING(contentCharset, "UTF-16BE"); +#endif rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, mIOThunk, - NS_LITERAL_CSTRING("text/html")); + contentType, contentCharset); if (NS_FAILED(rv)) return rv; rv = mIOThunk->Init(aURI);