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 | /* |
michael@0 | 2 | * Check that builtin character classes within ranges produce syntax |
michael@0 | 3 | * errors. |
michael@0 | 4 | * |
michael@0 | 5 | * Note that, per the extension in bug 351463, SpiderMonkey permits hyphens |
michael@0 | 6 | * adjacent to character class escapes in character classes, treating them as a |
michael@0 | 7 | * hyphen pattern character. Therefore /[\d-\s]/ is okay |
michael@0 | 8 | * |
michael@0 | 9 | * Note: /\b/ is the backspace escape, which is a single pattern character, |
michael@0 | 10 | * though it looks deceptively like a character class. |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | function isRegExpSyntaxError(pattern) { |
michael@0 | 14 | try { |
michael@0 | 15 | var re = new RegExp(pattern); |
michael@0 | 16 | } catch (e) { |
michael@0 | 17 | if (e instanceof SyntaxError) |
michael@0 | 18 | return true; |
michael@0 | 19 | } |
michael@0 | 20 | return false; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | assertEq(isRegExpSyntaxError('[C-\\s]'), true); |
michael@0 | 24 | assertEq(isRegExpSyntaxError('[C-\\d]'), true); |
michael@0 | 25 | assertEq(isRegExpSyntaxError('[C-\\W]'), true); |
michael@0 | 26 | assertEq(isRegExpSyntaxError('[C-]'), false); |
michael@0 | 27 | assertEq(isRegExpSyntaxError('[-C]'), false); |
michael@0 | 28 | assertEq(isRegExpSyntaxError('[C-C]'), false); |
michael@0 | 29 | assertEq(isRegExpSyntaxError('[C-C]'), false); |
michael@0 | 30 | assertEq(isRegExpSyntaxError('[\\b-\\b]'), false); |
michael@0 | 31 | assertEq(isRegExpSyntaxError('[\\B-\\B]'), false); |
michael@0 | 32 | assertEq(isRegExpSyntaxError('[\\b-\\B]'), false); |
michael@0 | 33 | assertEq(isRegExpSyntaxError('[\\B-\\b]'), true); |
michael@0 | 34 | assertEq(isRegExpSyntaxError('[\\b-\\w]'), true); |
michael@0 | 35 | assertEq(isRegExpSyntaxError('[\\B-\\w]'), true); |
michael@0 | 36 | |
michael@0 | 37 | /* Extension. */ |
michael@0 | 38 | assertEq(isRegExpSyntaxError('[\\s-\\s]'), false); |
michael@0 | 39 | assertEq(isRegExpSyntaxError('[\\W-\\s]'), false); |
michael@0 | 40 | assertEq(isRegExpSyntaxError('[\\s-\\W]'), false); |
michael@0 | 41 | assertEq(isRegExpSyntaxError('[\\W-C]'), false); |
michael@0 | 42 | assertEq(isRegExpSyntaxError('[\\d-C]'), false); |
michael@0 | 43 | assertEq(isRegExpSyntaxError('[\\s-C]'), false); |
michael@0 | 44 | assertEq(isRegExpSyntaxError('[\\w-\\b]'), false); |
michael@0 | 45 | assertEq(isRegExpSyntaxError('[\\w-\\B]'), false); |