Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | #!/user/local/bin/perl |
michael@0 | 2 | # -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 3 | # |
michael@0 | 4 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 7 | $rowwidth = ((0xff - 0x80)+(0x7f - 0x40)); |
michael@0 | 8 | sub cp936tonum() |
michael@0 | 9 | { |
michael@0 | 10 | my($cp936) = (@_); |
michael@0 | 11 | my($first,$second,$jnum); |
michael@0 | 12 | $first = hex(substr($cp936,2,2)); |
michael@0 | 13 | $second = hex(substr($cp936,4,2)); |
michael@0 | 14 | $jnum = ($first - 0x81 ) * $rowwidth; |
michael@0 | 15 | if($second >= 0x80) |
michael@0 | 16 | { |
michael@0 | 17 | $jnum += $second - 0x80 + (0x7f-0x40); |
michael@0 | 18 | } |
michael@0 | 19 | else |
michael@0 | 20 | { |
michael@0 | 21 | $jnum += $second - 0x40; |
michael@0 | 22 | } |
michael@0 | 23 | return $jnum; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | @map = {}; |
michael@0 | 27 | sub readtable() |
michael@0 | 28 | { |
michael@0 | 29 | open(CP936, "<gbkcommon.txt") || die "cannot open gbkcommon.txt"; |
michael@0 | 30 | while(<CP936>) |
michael@0 | 31 | { |
michael@0 | 32 | if(! /^#/) { |
michael@0 | 33 | chop(); |
michael@0 | 34 | ($j, $u, $r) = split(/\t/,$_); |
michael@0 | 35 | if(length($j) > 4) |
michael@0 | 36 | { |
michael@0 | 37 | $n = &cp936tonum($j); |
michael@0 | 38 | $map{$n} = $u; |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | |
michael@0 | 45 | sub printtable() |
michael@0 | 46 | { |
michael@0 | 47 | for($i=0;$i<126;$i++) |
michael@0 | 48 | { |
michael@0 | 49 | printf ( "/* 0x%2XXX */\n", ( $i + 0x81)); |
michael@0 | 50 | for($j=0;$j<(0x7f-0x40);$j++) |
michael@0 | 51 | { |
michael@0 | 52 | if("" eq ($map{($i * $rowwidth + $j)})) |
michael@0 | 53 | { |
michael@0 | 54 | printf "0xFFFD," |
michael@0 | 55 | } |
michael@0 | 56 | else |
michael@0 | 57 | { |
michael@0 | 58 | printf $map{($i * $rowwidth + $j)} . ","; |
michael@0 | 59 | } |
michael@0 | 60 | if( 0 == (($j + 1) % 8)) |
michael@0 | 61 | { |
michael@0 | 62 | printf "/* 0x%2X%1X%1X*/\n", $i+0x81, 4+($j/16), (7==($j%16))?0:8; |
michael@0 | 63 | } |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | print "0xFFFD,"; |
michael@0 | 67 | |
michael@0 | 68 | printf "/* 0x%2X%1X%1X*/\n", $i+0x81, 4+($j/16),(7==($j%16))?0:8; |
michael@0 | 69 | for($j=0;$j < (0xff-0x80);$j++) |
michael@0 | 70 | { |
michael@0 | 71 | if("" eq ($map{($i * $rowwidth + $j + 0x3f)})) # user defined chars map to 0xFFFD |
michael@0 | 72 | { |
michael@0 | 73 | |
michael@0 | 74 | if ( ( $i == 125 ) and ( $j == (0xff - 0x80 - 1 ))) |
michael@0 | 75 | { |
michael@0 | 76 | printf "0xFFFD"; #has no ',' followed last item |
michael@0 | 77 | } |
michael@0 | 78 | else |
michael@0 | 79 | { |
michael@0 | 80 | printf "0xFFFD,"; |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | else |
michael@0 | 84 | { |
michael@0 | 85 | if ( ( $i == 125 ) and ( $j == (0xff - 0x80 - 1 ))) |
michael@0 | 86 | { |
michael@0 | 87 | printf $map{($i * $rowwidth + $j + 0x3f)}; #has no ',' followed last item |
michael@0 | 88 | } |
michael@0 | 89 | else |
michael@0 | 90 | { |
michael@0 | 91 | printf $map{($i * $rowwidth + $j + 0x3f)} . ","; |
michael@0 | 92 | } |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | if( 0 == (($j + 1) % 8)) |
michael@0 | 96 | { |
michael@0 | 97 | printf "/* 0x%2X%1X%1X*/\n", $i+0x81, 8+($j/16), (7==($j%16))?0:8; |
michael@0 | 98 | } |
michael@0 | 99 | } |
michael@0 | 100 | printf " /* 0x%2X%1X%1X*/\n", $i+0x81, 8+($j/16),(7==($j%16))?0:8; |
michael@0 | 101 | } |
michael@0 | 102 | } |
michael@0 | 103 | sub printnpl() |
michael@0 | 104 | { |
michael@0 | 105 | $npl = <<END_OF_NPL; |
michael@0 | 106 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 107 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 108 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 109 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 110 | END_OF_NPL |
michael@0 | 111 | print $npl; |
michael@0 | 112 | } |
michael@0 | 113 | sub printdontmodify() |
michael@0 | 114 | { |
michael@0 | 115 | $dont_modify = <<END_OF_DONT_MODIFY; |
michael@0 | 116 | /* |
michael@0 | 117 | This file is generated by mozilla/intl/uconv/tools/cp936tocdx.pl |
michael@0 | 118 | Please do not modify this file by hand |
michael@0 | 119 | Instead, you should download CP936.TXT from |
michael@0 | 120 | http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/ |
michael@0 | 121 | and put under mozilla/intl/uconv/toools |
michael@0 | 122 | and run perl cp936tocdx.pl > ../ucvcn/cp936map.h |
michael@0 | 123 | If you have question, mailto:ftan\@netscape.com |
michael@0 | 124 | */ |
michael@0 | 125 | END_OF_DONT_MODIFY |
michael@0 | 126 | print $dont_modify; |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | &readtable(); |
michael@0 | 130 | &printnpl(); |
michael@0 | 131 | &printdontmodify(); |
michael@0 | 132 | &printtable(); |
michael@0 | 133 |