intl/chardet/tools/genhz.pl

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 #!/usr/local/bin/perl
michael@0 2 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5
michael@0 6 use strict;
michael@0 7 require "genverifier.pm";
michael@0 8 use genverifier;
michael@0 9
michael@0 10
michael@0 11 my(@hz_cls);
michael@0 12 my(@hz_st);
michael@0 13 my($hz_ver);
michael@0 14
michael@0 15
michael@0 16 #
michael@0 17 #
michael@0 18 # > 0x80 - 1
michael@0 19 # ~ - 2
michael@0 20 # LF - 3
michael@0 21 # { - 4
michael@0 22 # } - 5
michael@0 23 #
michael@0 24 @hz_cls = (
michael@0 25 [ 0x01 , 0x1a , 0 ],
michael@0 26 [ 0x7e , 0x7e , 2 ],
michael@0 27 [ 0x0a , 0x0a , 3 ],
michael@0 28 [ 0x7b , 0x7b , 4 ],
michael@0 29 [ 0x7d , 0x7d , 5 ],
michael@0 30 [ 0x1c , 0x7f , 0 ],
michael@0 31 [ 0x0e , 0x0f , 1 ],
michael@0 32 [ 0x1b , 0x1b , 1 ],
michael@0 33 [ 0x00 , 0x00 , 1 ],
michael@0 34 [ 0x80 , 0xff , 1 ]
michael@0 35 );
michael@0 36
michael@0 37
michael@0 38 #
michael@0 39 #
michael@0 40 package genverifier;
michael@0 41 @hz_st = (
michael@0 42 # 0 1 2 3 4 5
michael@0 43 0, 1, 3, 0, 0, 0, # Start State - 0
michael@0 44 1, 1, 1, 1, 1, 1, # Error State - 1
michael@0 45 2, 2, 2, 2, 2, 2, # ItsMe State - 2
michael@0 46 1, 1, 0, 0, 4, 1, # state 3 - got ~
michael@0 47 5, 1, 6, 1, 5, 5, # state 4 - got ~ {
michael@0 48 4, 1, 4, 1, 4, 4, # state 5 - got ~ { X
michael@0 49 4, 1, 4, 1, 4, 2, # state 6 - got ~ { [X X]* ~
michael@0 50 );
michael@0 51
michael@0 52 $hz_ver = genverifier::GenVerifier("HZ", "HZ-GB-2312",
michael@0 53 \@hz_cls, 6, \@hz_st);
michael@0 54 print $hz_ver;
michael@0 55
michael@0 56
michael@0 57

mercurial