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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | const LATIN1_AE = "\xc6"; |
michael@0 | 6 | const LATIN1_ae = "\xe6"; |
michael@0 | 7 | |
michael@0 | 8 | function setup() |
michael@0 | 9 | { |
michael@0 | 10 | getOpenedDatabase().createTable("t1", "x TEXT"); |
michael@0 | 11 | |
michael@0 | 12 | var stmt = createStatement("INSERT INTO t1 (x) VALUES ('foo/bar_baz%20cheese')"); |
michael@0 | 13 | stmt.execute(); |
michael@0 | 14 | stmt.finalize(); |
michael@0 | 15 | |
michael@0 | 16 | stmt = createStatement("INSERT INTO t1 (x) VALUES (?1)"); |
michael@0 | 17 | // insert LATIN_ae, but search on LATIN_AE |
michael@0 | 18 | stmt.bindByIndex(0, "foo%20" + LATIN1_ae + "/_bar"); |
michael@0 | 19 | stmt.execute(); |
michael@0 | 20 | stmt.finalize(); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function test_escape_for_like_ascii() |
michael@0 | 24 | { |
michael@0 | 25 | var stmt = createStatement("SELECT x FROM t1 WHERE x LIKE ?1 ESCAPE '/'"); |
michael@0 | 26 | var paramForLike = stmt.escapeStringForLIKE("oo/bar_baz%20chees", '/'); |
michael@0 | 27 | // verify that we escaped / _ and % |
michael@0 | 28 | do_check_eq(paramForLike, "oo//bar/_baz/%20chees"); |
michael@0 | 29 | // prepend and append with % for "contains" |
michael@0 | 30 | stmt.bindByIndex(0, "%" + paramForLike + "%"); |
michael@0 | 31 | stmt.executeStep(); |
michael@0 | 32 | do_check_eq("foo/bar_baz%20cheese", stmt.getString(0)); |
michael@0 | 33 | stmt.finalize(); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function test_escape_for_like_non_ascii() |
michael@0 | 37 | { |
michael@0 | 38 | var stmt = createStatement("SELECT x FROM t1 WHERE x LIKE ?1 ESCAPE '/'"); |
michael@0 | 39 | var paramForLike = stmt.escapeStringForLIKE("oo%20" + LATIN1_AE + "/_ba", '/'); |
michael@0 | 40 | // verify that we escaped / _ and % |
michael@0 | 41 | do_check_eq(paramForLike, "oo/%20" + LATIN1_AE + "///_ba"); |
michael@0 | 42 | // prepend and append with % for "contains" |
michael@0 | 43 | stmt.bindByIndex(0, "%" + paramForLike + "%"); |
michael@0 | 44 | stmt.executeStep(); |
michael@0 | 45 | do_check_eq("foo%20" + LATIN1_ae + "/_bar", stmt.getString(0)); |
michael@0 | 46 | stmt.finalize(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | var tests = [test_escape_for_like_ascii, test_escape_for_like_non_ascii]; |
michael@0 | 50 | |
michael@0 | 51 | function run_test() |
michael@0 | 52 | { |
michael@0 | 53 | setup(); |
michael@0 | 54 | |
michael@0 | 55 | for (var i = 0; i < tests.length; i++) |
michael@0 | 56 | tests[i](); |
michael@0 | 57 | |
michael@0 | 58 | cleanup(); |
michael@0 | 59 | } |