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 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
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 | /* |
michael@0 | 7 | * |
michael@0 | 8 | * Date: 22 Aug 2009 |
michael@0 | 9 | * SUMMARY: Utf8ToOneUcs4Char in jsstr.cpp ,overlong UTF-8 seqence detection problem |
michael@0 | 10 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=511859 |
michael@0 | 11 | * |
michael@0 | 12 | */ |
michael@0 | 13 | //----------------------------------------------------------------------------- |
michael@0 | 14 | var UBound = 0; |
michael@0 | 15 | var BUGNUMBER = 511859; |
michael@0 | 16 | var summary = 'Utf8ToOneUcs4Char in jsstr.cpp ,overlong UTF-8 seqence detection problem'; |
michael@0 | 17 | var status = ''; |
michael@0 | 18 | var statusitems = []; |
michael@0 | 19 | var actual = ''; |
michael@0 | 20 | var actualvalues = []; |
michael@0 | 21 | var expect = ''; |
michael@0 | 22 | var expectedvalues = []; |
michael@0 | 23 | var arg; |
michael@0 | 24 | /* |
michael@0 | 25 | * The patch for http://bugzilla.mozilla.org/show_bug.cgi?id=511859 |
michael@0 | 26 | * defined this value to be the result of an overlong UTF-8 sequence - |
michael@0 | 27 | */ |
michael@0 | 28 | |
michael@0 | 29 | var EX="(Exception thrown)"; |
michael@0 | 30 | |
michael@0 | 31 | function getActual(s) |
michael@0 | 32 | { |
michael@0 | 33 | try { |
michael@0 | 34 | return decodeURI(s); |
michael@0 | 35 | } catch (e) { |
michael@0 | 36 | return EX; |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | //Phase1: overlong sequences |
michael@0 | 41 | expect = EX; |
michael@0 | 42 | arg = "%C1%BF"; |
michael@0 | 43 | status = "Overlong 2byte U+7f :" + arg; |
michael@0 | 44 | actual = getActual(arg); |
michael@0 | 45 | addThis(); |
michael@0 | 46 | |
michael@0 | 47 | arg = "%E0%9F%BF"; |
michael@0 | 48 | status = "Overlong 3byte U+7ff :" + arg; |
michael@0 | 49 | actual = getActual(arg); |
michael@0 | 50 | addThis(); |
michael@0 | 51 | |
michael@0 | 52 | arg = "%F0%88%80%80"; |
michael@0 | 53 | status = "Overlong 4byte U+8000 :" + arg; |
michael@0 | 54 | actual = getActual(arg); |
michael@0 | 55 | addThis(); |
michael@0 | 56 | |
michael@0 | 57 | arg = "%F0%8F%BF%BF"; |
michael@0 | 58 | status = "Overlong 4byte U+ffff :" + arg; |
michael@0 | 59 | actual = getActual(arg); |
michael@0 | 60 | addThis(); |
michael@0 | 61 | |
michael@0 | 62 | arg = "%F0%80%C0%80%80"; |
michael@0 | 63 | status = "Overlong 5byte U+20000 :" + arg; |
michael@0 | 64 | actual = getActual(arg); |
michael@0 | 65 | addThis(); |
michael@0 | 66 | |
michael@0 | 67 | arg = "%F8%84%8F%BF%BF"; |
michael@0 | 68 | status = "Overlong 5byte U+10FFFF :" + arg; |
michael@0 | 69 | actual = getActual(arg); |
michael@0 | 70 | addThis(); |
michael@0 | 71 | |
michael@0 | 72 | arg = "%FC%80%84%8F%BF%BF"; |
michael@0 | 73 | status = "Overlong 6byte U+10FFFF :" + arg; |
michael@0 | 74 | actual = getActual(arg); |
michael@0 | 75 | addThis(); |
michael@0 | 76 | |
michael@0 | 77 | //Phase 2:Out of Unicode range |
michael@0 | 78 | arg = "%F4%90%80%80%80"; |
michael@0 | 79 | status = "4byte 0x110000 :" + arg; |
michael@0 | 80 | actual = getActual(arg); |
michael@0 | 81 | addThis(); |
michael@0 | 82 | arg = "%F8%84%90%80%80"; |
michael@0 | 83 | status = "5byte 0x110000 :" + arg; |
michael@0 | 84 | actual = getActual(arg); |
michael@0 | 85 | addThis(); |
michael@0 | 86 | |
michael@0 | 87 | arg = "%FC%80%84%90%80%80"; |
michael@0 | 88 | status = "6byte 0x110000 :" + arg; |
michael@0 | 89 | actual = getActual(arg); |
michael@0 | 90 | addThis(); |
michael@0 | 91 | |
michael@0 | 92 | //Phase 3:Valid sequences must be decoded correctly |
michael@0 | 93 | arg = "%7F"; |
michael@0 | 94 | status = "valid sequence U+7F :" + arg; |
michael@0 | 95 | actual = getActual("%7F"); |
michael@0 | 96 | expect = "\x7f"; |
michael@0 | 97 | addThis(); |
michael@0 | 98 | |
michael@0 | 99 | arg = "%C2%80"; |
michael@0 | 100 | status = "valid sequence U+80 :" + arg; |
michael@0 | 101 | actual = getActual(arg); |
michael@0 | 102 | expect = "\x80"; |
michael@0 | 103 | addThis(); |
michael@0 | 104 | |
michael@0 | 105 | arg = "%E0%A0%80"; |
michael@0 | 106 | status = "valid sequence U+800 :" + arg; |
michael@0 | 107 | actual = getActual("%E0%A0%80"); |
michael@0 | 108 | expect = "\u0800"; |
michael@0 | 109 | addThis(); |
michael@0 | 110 | |
michael@0 | 111 | arg = "%F0%90%80%80" |
michael@0 | 112 | status = "valid sequence U+10000 :" + arg; |
michael@0 | 113 | actual = getActual(arg); |
michael@0 | 114 | expect = "\uD800\uDC00"; |
michael@0 | 115 | addThis(); |
michael@0 | 116 | |
michael@0 | 117 | arg = "%F4%8F%BF%BF"; |
michael@0 | 118 | status = "valid sequence U+10FFFF :" + arg; |
michael@0 | 119 | actual = getActual(arg); |
michael@0 | 120 | expect = "\uDBFF\uDFFF"; |
michael@0 | 121 | addThis(); |
michael@0 | 122 | |
michael@0 | 123 | //----------------------------------------------------------------------------- |
michael@0 | 124 | test(); |
michael@0 | 125 | //----------------------------------------------------------------------------- |
michael@0 | 126 | |
michael@0 | 127 | |
michael@0 | 128 | |
michael@0 | 129 | function addThis() |
michael@0 | 130 | { |
michael@0 | 131 | statusitems[UBound] = status; |
michael@0 | 132 | actualvalues[UBound] = actual; |
michael@0 | 133 | expectedvalues[UBound] = expect; |
michael@0 | 134 | UBound++; |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | |
michael@0 | 138 | function test() |
michael@0 | 139 | { |
michael@0 | 140 | enterFunc('test'); |
michael@0 | 141 | printBugNumber(BUGNUMBER); |
michael@0 | 142 | printStatus(summary); |
michael@0 | 143 | |
michael@0 | 144 | for (var i=0; i<UBound; i++) |
michael@0 | 145 | { |
michael@0 | 146 | reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
michael@0 | 147 | } |
michael@0 | 148 | |
michael@0 | 149 | exitFunc('test'); |
michael@0 | 150 | } |