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 | * Copyright (c) 1999 |
michael@0 | 3 | * Silicon Graphics Computer Systems, Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Copyright (c) 1999 |
michael@0 | 6 | * Boris Fomitchev |
michael@0 | 7 | * |
michael@0 | 8 | * This material is provided "as is", with absolutely no warranty expressed |
michael@0 | 9 | * or implied. Any use is at your own risk. |
michael@0 | 10 | * |
michael@0 | 11 | * Permission to use or copy this software for any purpose is hereby granted |
michael@0 | 12 | * without fee, provided the above notices are retained on all copies. |
michael@0 | 13 | * Permission to modify the code and to distribute modified code is granted, |
michael@0 | 14 | * provided the above notices are retained, and a notice that the code was |
michael@0 | 15 | * modified is included with the above copyright notice. |
michael@0 | 16 | * |
michael@0 | 17 | */ |
michael@0 | 18 | #include "stlport_prefix.h" |
michael@0 | 19 | |
michael@0 | 20 | #include <locale> |
michael@0 | 21 | #include <istream> |
michael@0 | 22 | #include <algorithm> |
michael@0 | 23 | |
michael@0 | 24 | _STLP_BEGIN_NAMESPACE |
michael@0 | 25 | _STLP_MOVE_TO_PRIV_NAMESPACE |
michael@0 | 26 | |
michael@0 | 27 | // __valid_grouping compares two strings, one representing the |
michael@0 | 28 | // group sizes encountered when reading an integer, and the other |
michael@0 | 29 | // representing the valid group sizes as returned by the numpunct |
michael@0 | 30 | // grouping() member function. Both are interpreted right-to-left. |
michael@0 | 31 | // The grouping string is treated as if it were extended indefinitely |
michael@0 | 32 | // with its last value. For a grouping to be valid, each term in |
michael@0 | 33 | // the first string must be equal to the corresponding term in the |
michael@0 | 34 | // second, except for the last, which must be less than or equal. |
michael@0 | 35 | |
michael@0 | 36 | // boris : this takes reversed first string ! |
michael@0 | 37 | bool _STLP_CALL |
michael@0 | 38 | __valid_grouping(const char * first1, const char * last1, |
michael@0 | 39 | const char * first2, const char * last2) { |
michael@0 | 40 | if (first1 == last1 || first2 == last2) return true; |
michael@0 | 41 | |
michael@0 | 42 | --last1; --last2; |
michael@0 | 43 | |
michael@0 | 44 | while (first1 != last1) { |
michael@0 | 45 | if (*last1 != *first2) |
michael@0 | 46 | return false; |
michael@0 | 47 | --last1; |
michael@0 | 48 | if (first2 != last2) ++first2; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | return *last1 <= *first2; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | _STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index) { |
michael@0 | 55 | static const unsigned char __val_table[128] = { |
michael@0 | 56 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
michael@0 | 57 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
michael@0 | 58 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
michael@0 | 59 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
michael@0 | 60 | 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
michael@0 | 61 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
michael@0 | 62 | 0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, |
michael@0 | 63 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | return __val_table[__index]; |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | _STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms() |
michael@0 | 70 | { return "+-0xX"; } |
michael@0 | 71 | |
michael@0 | 72 | // index is actually a char |
michael@0 | 73 | |
michael@0 | 74 | #if !defined (_STLP_NO_WCHAR_T) |
michael@0 | 75 | |
michael@0 | 76 | // Similar, except return the character itself instead of the numeric |
michael@0 | 77 | // value. Used for floating-point input. |
michael@0 | 78 | bool _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits) { |
michael@0 | 79 | const wchar_t* p = find(digits, digits + 10, c); |
michael@0 | 80 | if (p != digits + 10) { |
michael@0 | 81 | c = (char)('0' + (p - digits)); |
michael@0 | 82 | return true; |
michael@0 | 83 | } |
michael@0 | 84 | else |
michael@0 | 85 | return false; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | bool _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep, |
michael@0 | 89 | const wchar_t * digits) { |
michael@0 | 90 | if (c == sep) { |
michael@0 | 91 | c = (char)','; |
michael@0 | 92 | return true; |
michael@0 | 93 | } |
michael@0 | 94 | else |
michael@0 | 95 | return __get_fdigit(c, digits); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | #endif |
michael@0 | 99 | |
michael@0 | 100 | _STLP_MOVE_TO_STD_NAMESPACE |
michael@0 | 101 | |
michael@0 | 102 | #if !defined(_STLP_NO_FORCE_INSTANTIATE) |
michael@0 | 103 | //---------------------------------------------------------------------- |
michael@0 | 104 | // Force instantiation of num_get<> |
michael@0 | 105 | template class _STLP_CLASS_DECLSPEC istreambuf_iterator<char, char_traits<char> >; |
michael@0 | 106 | // template class num_get<char, const char*>; |
michael@0 | 107 | template class num_get<char, istreambuf_iterator<char, char_traits<char> > >; |
michael@0 | 108 | |
michael@0 | 109 | # if !defined (_STLP_NO_WCHAR_T) |
michael@0 | 110 | template class _STLP_CLASS_DECLSPEC istreambuf_iterator<wchar_t, char_traits<wchar_t> >; |
michael@0 | 111 | template class num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >; |
michael@0 | 112 | // template class num_get<wchar_t, const wchar_t*>; |
michael@0 | 113 | # endif |
michael@0 | 114 | #endif |
michael@0 | 115 | |
michael@0 | 116 | _STLP_END_NAMESPACE |
michael@0 | 117 | |
michael@0 | 118 | // Local Variables: |
michael@0 | 119 | // mode:C++ |
michael@0 | 120 | // End: |