From 6a8d60b403efdd9db30ac4a1a0d27fcb1db43bcc Mon Sep 17 00:00:00 2001 From: Shawn Wilsher Date: Wed, 17 Jun 2009 12:13:02 -0700 Subject: [PATCH] Bug 494217 - nsINetUtil::unescapeString drops high bytes of UTF-16 strings from JS This fixes an issue where unescapeString will drop the high bytes of a UTF-16 string when unescaping, resulting in a loss of data. r=bz sr=bz --- netwerk/base/public/nsINetUtil.idl | 4 ++-- netwerk/test/unit/test_unescapestring.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/netwerk/base/public/nsINetUtil.idl b/netwerk/base/public/nsINetUtil.idl index 529d25870087..f9c271bfae52 100644 --- a/netwerk/base/public/nsINetUtil.idl +++ b/netwerk/base/public/nsINetUtil.idl @@ -46,7 +46,7 @@ interface nsIPrefBranch; /** * nsINetUtil provides various network-related utility methods. */ -[scriptable, uuid(57322c6f-f4ec-4e46-8253-b74be220de16)] +[scriptable, uuid(a50d5516-5c0a-4f08-b427-703ca0c44ac3)] interface nsINetUtil : nsISupports { /** @@ -192,7 +192,7 @@ interface nsINetUtil : nsISupports * unescaped * @return unescaped string */ - ACString unescapeString(in ACString aStr, in unsigned long aFlags); + ACString unescapeString(in AUTF8String aStr, in unsigned long aFlags); /** * Extract the charset parameter location and value from a content-type diff --git a/netwerk/test/unit/test_unescapestring.js b/netwerk/test/unit/test_unescapestring.js index 7fb638e277ca..d1e9494cd77b 100644 --- a/netwerk/test/unit/test_unescapestring.js +++ b/netwerk/test/unit/test_unescapestring.js @@ -13,7 +13,9 @@ var tests = [ ["foo%ffbar", "foo\xffbar", 0], ["%00%1b%20%61%7f%80%ff", "%00%1b%20%61%7f\x80\xff", ONLY_NONASCII], ["%00%1b%20%61%7f%80%ff", "%00%1b a%7f\x80\xff", SKIP_CONTROL], - ["%00%1b%20%61%7f%80%ff", "%00%1b%20%61%7f\x80\xff", ONLY_NONASCII|SKIP_CONTROL] + ["%00%1b%20%61%7f%80%ff", "%00%1b%20%61%7f\x80\xff", ONLY_NONASCII|SKIP_CONTROL], + // Test that we do not drop the high-bytes of a UTF-16 string. + ["\u30a8\u30c9", "\xe3\x82\xa8\xe3\x83\x89", 0], ]; function run_test() {