Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright 2009 the Sputnik authors. All rights reserved. |
michael@0 | 2 | // This code is governed by the BSD license found in the LICENSE file. |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * If multi line comments csn not nest, they can contain any Unicode character |
michael@0 | 6 | * |
michael@0 | 7 | * @path ch07/7.4/S7.4_A6.js |
michael@0 | 8 | * @description "var"+ yy+ "xx = 1", insert instead of yy all Unicode characters |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | //CHECK |
michael@0 | 12 | var errorCount = 0; |
michael@0 | 13 | var count = 0; |
michael@0 | 14 | for (var indexI = 0; indexI <= 65535; indexI++) { |
michael@0 | 15 | try { |
michael@0 | 16 | var xx = 0; |
michael@0 | 17 | eval("/*var " + String.fromCharCode(indexI) + "xx = 1*/"); |
michael@0 | 18 | var hex = decimalToHexString(indexI); |
michael@0 | 19 | if (xx !== 0) { |
michael@0 | 20 | $ERROR('#' + hex + ' '); |
michael@0 | 21 | errorCount++; |
michael@0 | 22 | } |
michael@0 | 23 | } catch (e){ |
michael@0 | 24 | $ERROR('#' + hex + ' '); |
michael@0 | 25 | errorCount++; |
michael@0 | 26 | } |
michael@0 | 27 | count++; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | if (errorCount > 0) { |
michael@0 | 31 | $ERROR('Total error: ' + errorCount + ' bad Unicode character in ' + count); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function decimalToHexString(n) { |
michael@0 | 35 | n = Number(n); |
michael@0 | 36 | var h = ""; |
michael@0 | 37 | for (var i = 3; i >= 0; i--) { |
michael@0 | 38 | if (n >= Math.pow(16, i)) { |
michael@0 | 39 | var t = Math.floor(n / Math.pow(16, i)); |
michael@0 | 40 | n -= t * Math.pow(16, i); |
michael@0 | 41 | if ( t >= 10 ) { |
michael@0 | 42 | if ( t == 10 ) { h += "A"; } |
michael@0 | 43 | if ( t == 11 ) { h += "B"; } |
michael@0 | 44 | if ( t == 12 ) { h += "C"; } |
michael@0 | 45 | if ( t == 13 ) { h += "D"; } |
michael@0 | 46 | if ( t == 14 ) { h += "E"; } |
michael@0 | 47 | if ( t == 15 ) { h += "F"; } |
michael@0 | 48 | } else { |
michael@0 | 49 | h += String(t); |
michael@0 | 50 | } |
michael@0 | 51 | } else { |
michael@0 | 52 | h += "0"; |
michael@0 | 53 | } |
michael@0 | 54 | } |
michael@0 | 55 | return h; |
michael@0 | 56 | } |
michael@0 | 57 |