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 | #ifndef prefread_h__ |
michael@0 | 6 | #define prefread_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "prefapi.h" |
michael@0 | 9 | |
michael@0 | 10 | #ifdef __cplusplus |
michael@0 | 11 | extern "C" { |
michael@0 | 12 | #endif |
michael@0 | 13 | |
michael@0 | 14 | /** |
michael@0 | 15 | * Callback function used to notify consumer of preference name value pairs. |
michael@0 | 16 | * The pref name and value must be copied by the implementor of the callback |
michael@0 | 17 | * if they are needed beyond the scope of the callback function. |
michael@0 | 18 | * |
michael@0 | 19 | * @param closure |
michael@0 | 20 | * user data passed to PREF_InitParseState |
michael@0 | 21 | * @param pref |
michael@0 | 22 | * preference name |
michael@0 | 23 | * @param val |
michael@0 | 24 | * preference value |
michael@0 | 25 | * @param type |
michael@0 | 26 | * preference type (PREF_STRING, PREF_INT, or PREF_BOOL) |
michael@0 | 27 | * @param defPref |
michael@0 | 28 | * preference type (true: default, false: user preference) |
michael@0 | 29 | */ |
michael@0 | 30 | typedef void (*PrefReader)(void *closure, |
michael@0 | 31 | const char *pref, |
michael@0 | 32 | PrefValue val, |
michael@0 | 33 | PrefType type, |
michael@0 | 34 | bool defPref); |
michael@0 | 35 | |
michael@0 | 36 | /* structure fields are private */ |
michael@0 | 37 | typedef struct PrefParseState { |
michael@0 | 38 | PrefReader reader; |
michael@0 | 39 | void *closure; |
michael@0 | 40 | int state; /* PREF_PARSE_... */ |
michael@0 | 41 | int nextstate; /* sometimes used... */ |
michael@0 | 42 | const char *smatch; /* string to match */ |
michael@0 | 43 | int sindex; /* next char of smatch to check */ |
michael@0 | 44 | /* also, counter in \u parsing */ |
michael@0 | 45 | char16_t utf16[2]; /* parsing UTF16 (\u) escape */ |
michael@0 | 46 | int esclen; /* length in esctmp */ |
michael@0 | 47 | char esctmp[6]; /* raw escape to put back if err */ |
michael@0 | 48 | char quotechar; /* char delimiter for quotations */ |
michael@0 | 49 | char *lb; /* line buffer (only allocation) */ |
michael@0 | 50 | char *lbcur; /* line buffer cursor */ |
michael@0 | 51 | char *lbend; /* line buffer end */ |
michael@0 | 52 | char *vb; /* value buffer (ptr into lb) */ |
michael@0 | 53 | PrefType vtype; /* PREF_STRING,INT,BOOL */ |
michael@0 | 54 | bool fdefault; /* true if (default) pref */ |
michael@0 | 55 | } PrefParseState; |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * PREF_InitParseState |
michael@0 | 59 | * |
michael@0 | 60 | * Called to initialize a PrefParseState instance. |
michael@0 | 61 | * |
michael@0 | 62 | * @param ps |
michael@0 | 63 | * PrefParseState instance. |
michael@0 | 64 | * @param reader |
michael@0 | 65 | * PrefReader callback function, which will be called once for each |
michael@0 | 66 | * preference name value pair extracted. |
michael@0 | 67 | * @param closure |
michael@0 | 68 | * PrefReader closure. |
michael@0 | 69 | */ |
michael@0 | 70 | void PREF_InitParseState(PrefParseState *ps, PrefReader reader, void *closure); |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * PREF_FinalizeParseState |
michael@0 | 74 | * |
michael@0 | 75 | * Called to release any memory in use by the PrefParseState instance. |
michael@0 | 76 | * |
michael@0 | 77 | * @param ps |
michael@0 | 78 | * PrefParseState instance. |
michael@0 | 79 | */ |
michael@0 | 80 | void PREF_FinalizeParseState(PrefParseState *ps); |
michael@0 | 81 | |
michael@0 | 82 | /** |
michael@0 | 83 | * PREF_ParseBuf |
michael@0 | 84 | * |
michael@0 | 85 | * Called to parse a buffer containing some portion of a preference file. This |
michael@0 | 86 | * function may be called repeatedly as new data is made available. The |
michael@0 | 87 | * PrefReader callback function passed PREF_InitParseState will be called as |
michael@0 | 88 | * preference name value pairs are extracted from the data. |
michael@0 | 89 | * |
michael@0 | 90 | * @param ps |
michael@0 | 91 | * PrefParseState instance. Must have been initialized. |
michael@0 | 92 | * @param buf |
michael@0 | 93 | * Raw buffer containing data to be parsed. |
michael@0 | 94 | * @param bufLen |
michael@0 | 95 | * Length of buffer. |
michael@0 | 96 | * |
michael@0 | 97 | * @return false if buffer contains malformed content. |
michael@0 | 98 | */ |
michael@0 | 99 | bool PREF_ParseBuf(PrefParseState *ps, const char *buf, int bufLen); |
michael@0 | 100 | |
michael@0 | 101 | #ifdef __cplusplus |
michael@0 | 102 | } |
michael@0 | 103 | #endif |
michael@0 | 104 | #endif /* prefread_h__ */ |