intl/locale/src/nsUConvPropertySearch.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "nsUConvPropertySearch.h"
     6 #include "nsCRT.h"
     7 #include "nsString.h"
     9 // static
    10 nsresult
    11 nsUConvPropertySearch::SearchPropertyValue(const char* aProperties[][3],
    12                                            int32_t aNumberOfProperties,
    13                                            const nsACString& aKey,
    14                                            nsACString& aValue)
    15 {
    16   const char* key = PromiseFlatCString(aKey).get();
    17   int32_t lo = 0;
    18   int32_t hi = aNumberOfProperties - 1;
    19   while (lo <= hi) {
    20     uint32_t mid = (lo + hi) / 2;
    21     int32_t comp = nsCRT::strcmp(aProperties[mid][0], key);
    22     if (comp > 0) {
    23       hi = mid - 1;
    24     } else if (comp < 0) {
    25       lo = mid + 1;
    26     } else {
    27       nsDependentCString val(aProperties[mid][1],
    28                              NS_PTR_TO_UINT32(aProperties[mid][2]));
    29       aValue.Assign(val);
    30       return NS_OK;
    31     }
    32   }
    33   aValue.Truncate();
    34   return NS_ERROR_FAILURE;
    35 }

mercurial