diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /intl/uconv/tests/unit/test_bug715319.dbcs.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'intl/uconv/tests/unit/test_bug715319.dbcs.js')
-rw-r--r-- | intl/uconv/tests/unit/test_bug715319.dbcs.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/intl/uconv/tests/unit/test_bug715319.dbcs.js b/intl/uconv/tests/unit/test_bug715319.dbcs.js new file mode 100644 index 000000000..a3dc4529f --- /dev/null +++ b/intl/uconv/tests/unit/test_bug715319.dbcs.js @@ -0,0 +1,54 @@ +// 2-byte charsets:
+const charsets = [ "Big5", "EUC-KR" ]
+const ScriptableUnicodeConverter =
+ Components.Constructor("@mozilla.org/intl/scriptableunicodeconverter",
+ "nsIScriptableUnicodeConverter");
+var gConverter;
+
+function error(inString, outString, msg) {
+ var dispIn = "";
+ var dispOut = "";
+ var i;
+ for (i = 0; i < inString.length; ++i) {
+ dispIn += " x" + inString.charCodeAt(i).toString(16);
+ }
+ if (outString.length == 0) {
+ dispOut = "<empty>";
+ } else {
+ for (i = 0; i < outString.length; ++i) {
+ dispOut += " x" + outString.charCodeAt(i).toString(16);
+ }
+ }
+ dump("\"" + dispIn + "\" ==> \"" + dispOut + "\"\n");
+ do_throw("security risk: " + msg);
+}
+
+function IsASCII(charCode) {
+ return (charCode <= 0x7e);
+}
+
+function test(inString) {
+ var outString = gConverter.ConvertToUnicode(inString) +
+ gConverter.Finish();
+
+ var outLen = outString.length;
+
+ if (IsASCII(inString.charCodeAt(1)) &&
+ (outLen < 4 || outString.charCodeAt(outLen - 4) == 0xFFFD)) {
+ error(inString, outString, "ASCII input eaten in " + gConverter.charset);
+ }
+}
+
+function run_test() {
+ gConverter = new ScriptableUnicodeConverter();
+ for (var i = 0; i < charsets.length; ++i) {
+ gConverter.charset = charsets[i];
+
+ var byte1, byte2;
+ for (byte1 = 1; byte1 < 0x100; ++byte1) {
+ for (byte2 = 1; byte2 < 0x100; ++byte2) {
+ test(String.fromCharCode(byte1, byte2) + "foo");
+ }
+ }
+ }
+}
|