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 | #include "nsReplacementToUnicode.h" |
michael@0 | 6 | |
michael@0 | 7 | nsReplacementToUnicode::nsReplacementToUnicode() |
michael@0 | 8 | : mSeenByte(false) |
michael@0 | 9 | { |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | NS_IMETHODIMP |
michael@0 | 13 | nsReplacementToUnicode::Convert(const char* aSrc, |
michael@0 | 14 | int32_t* aSrcLength, |
michael@0 | 15 | char16_t* aDest, |
michael@0 | 16 | int32_t* aDestLength) |
michael@0 | 17 | { |
michael@0 | 18 | if (mSeenByte || !(*aSrcLength)) { |
michael@0 | 19 | *aDestLength = 0; |
michael@0 | 20 | return NS_PARTIAL_MORE_INPUT; |
michael@0 | 21 | } |
michael@0 | 22 | if (mErrBehavior == kOnError_Signal) { |
michael@0 | 23 | mSeenByte = true; |
michael@0 | 24 | *aSrcLength = 0; |
michael@0 | 25 | *aDestLength = 0; |
michael@0 | 26 | return NS_ERROR_ILLEGAL_INPUT; |
michael@0 | 27 | } |
michael@0 | 28 | if (!(*aDestLength)) { |
michael@0 | 29 | *aSrcLength = -1; |
michael@0 | 30 | return NS_PARTIAL_MORE_OUTPUT; |
michael@0 | 31 | } |
michael@0 | 32 | mSeenByte = true; |
michael@0 | 33 | *aDest = 0xFFFD; |
michael@0 | 34 | *aDestLength = 1; |
michael@0 | 35 | return NS_PARTIAL_MORE_INPUT; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | NS_IMETHODIMP |
michael@0 | 39 | nsReplacementToUnicode::GetMaxLength(const char* aSrc, |
michael@0 | 40 | int32_t aSrcLength, |
michael@0 | 41 | int32_t* aDestLength) |
michael@0 | 42 | { |
michael@0 | 43 | if (!mSeenByte && aSrcLength > 0) { |
michael@0 | 44 | *aDestLength = 1; |
michael@0 | 45 | } else { |
michael@0 | 46 | *aDestLength = 0; |
michael@0 | 47 | } |
michael@0 | 48 | return NS_EXACT_LENGTH; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | NS_IMETHODIMP |
michael@0 | 52 | nsReplacementToUnicode::Reset() |
michael@0 | 53 | { |
michael@0 | 54 | mSeenByte = false; |
michael@0 | 55 | return NS_OK; |
michael@0 | 56 | } |