/** * HTTP API: WP_Http_Cookie class * * @package WordPress * @subpackage HTTP * @since 4.4.0 */ /** * Core class used to encapsulate a single cookie object for internal use. * * Returned cookies are represented using this class, and when cookies are set, if they are not * already a WP_Http_Cookie() object, then they are turned into one. * * @todo The WordPress convention is to use underscores instead of camelCase for function and method * names. Need to switch to use underscores instead for the methods. * * @since 2.8.0 */ #[AllowDynamicProperties] class WP_Http_Cookie { /** * Cookie name. * * @since 2.8.0 * * @var string */ public $name; /** * Cookie value. * * @since 2.8.0 * * @var string */ public $value; /** * When the cookie expires. Unix timestamp or formatted date. * * @since 2.8.0 * * @var string|int|null */ public $expires; /** * Cookie URL path. * * @since 2.8.0 * * @var string */ public $path; /** * Cookie Domain. * * @since 2.8.0 * * @var string */ public $domain; /** * Cookie port or comma-separated list of ports. * * @since 2.8.0 * * @var int|string */ public $port; /** * host-only flag. * * @since 5.2.0 * * @var bool */ public $host_only; /** * Sets up this cookie object. * * The parameter $data should be either an associative array containing the indices names below * or a header string detailing it. * * @since 2.8.0 * @since 5.2.0 Added `host_only` to the `$data` parameter. * * @param string|array $data { * Raw cookie data as header string or data array. * * @type string $name Cookie name. * @type mixed $value Value. Should NOT already be urlencoded. * @type string|int|null $expires Optional. Unix timestamp or formatted date. Default null. * @type string $path Optional. Path. Default '/'. * @type string $domain Optional. Domain. Default host of parsed $requested_url. * @type int|string $port Optional. Port or comma-separated list of ports. Default null. * @type bool $host_only Optional. host-only storage flag. Default true. * } * @param string $requested_url The URL which the cookie was set on, used for default $domain * and $port values. */ public function __construct( $data, $requested_url = '' ) { if ( $requested_url ) { $parsed_url = parse_url( $requested_url ); } if ( isset( $parsed_url['host'] ) ) { $this->domain = $parsed_url['host']; } $this->path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '/'; if ( ! str_ends_with( $this->path, '/' ) ) { $this->path = dirname( $this->path ) . '/'; } if ( is_string( $data ) ) { // Assume it's a header string direct from a previous request. $pairs = explode( ';', $data ); // Special handling for first pair; name=value. Also be careful of "=" in value. $name = trim( substr( $pairs[0], 0, strpos( $pairs[0], '=' ) ) ); $value = substr( $pairs[0], strpos( $pairs[0], '=' ) + 1 ); $this->name = $name; $this->value = urldecode( $value ); // Removes name=value from items. array_shift( $pairs ); // Set everything else as a property. foreach ( $pairs as $pair ) { $pair = rtrim( $pair ); // Handle the cookie ending in ; which results in an empty final pair. if ( empty( $pair ) ) { continue; } list( $key, $val ) = strpos( $pair, '=' ) ? explode( '=', $pair ) : array( $pair, '' ); $key = strtolower( trim( $key ) ); if ( 'expires' === $key ) { $val = strtotime( $val ); } $this->$key = $val; } } else { if ( ! isset( $data['name'] ) ) { return; } // Set properties based directly on parameters. foreach ( array( 'name', 'value', 'path', 'domain', 'port', 'host_only' ) as $field ) { if ( isset( $data[ $field ] ) ) { $this->$field = $data[ $field ]; } } if ( isset( $data['expires'] ) ) { $this->expires = is_int( $data['expires'] ) ? $data['expires'] : strtotime( $data['expires'] ); } else { $this->expires = null; } } } /** * Confirms that it's OK to send this cookie to the URL checked against. * * Decision is based on RFC 2109/2965, so look there for details on validity. * * @since 2.8.0 * * @param string $url URL you intend to send this cookie to * @return bool true if allowed, false otherwise. */ public function test( $url ) { if ( is_null( $this->name ) ) { return false; } // Expires - if expired then nothing else matters. if ( isset( $this->expires ) && time() > $this->expires ) { return false; } // Get details on the URL we're thinking about sending to. $url = parse_url( $url ); $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' === $url['scheme'] ? 443 : 80 ); $url['path'] = isset( $url['path'] ) ? $url['path'] : '/'; // Values to use for comparison against the URL. $path = isset( $this->path ) ? $this->path : '/'; $port = isset( $this->port ) ? $this->port : null; $domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] ); if ( false === stripos( $domain, '.' ) ) { $domain .= '.local'; } // Host - very basic check that the request URL ends with the domain restriction (minus leading dot). $domain = ( str_starts_with( $domain, '.' ) ) ? substr( $domain, 1 ) : $domain; if ( ! str_ends_with( $url['host'], $domain ) ) { return false; } // Port - supports "port-lists" in the format: "80,8000,8080". if ( ! empty( $port ) && ! in_array( $url['port'], array_map( 'intval', explode( ',', $port ) ), true ) ) { return false; } // Path - request path must start with path restriction. if ( ! str_starts_with( $url['path'], $path ) ) { return false; } return true; } /** * Convert cookie name and value back to header string. * * @since 2.8.0 * * @return string Header encoded cookie name and value. */ public function getHeaderValue() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid if ( ! isset( $this->name ) || ! isset( $this->value ) ) { return ''; } /** * Filters the header-encoded cookie value. * * @since 3.4.0 * * @param string $value The cookie value. * @param string $name The cookie name. */ return $this->name . '=' . apply_filters( 'wp_http_cookie_value', $this->value, $this->name ); } /** * Retrieve cookie header for usage in the rest of the WordPress HTTP API. * * @since 2.8.0 * * @return string */ public function getFullHeader() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid return 'Cookie: ' . $this->getHeaderValue(); } /** * Retrieves cookie attributes. * * @since 4.6.0 * * @return array { * List of attributes. * * @type string|int|null $expires When the cookie expires. Unix timestamp or formatted date. * @type string $path Cookie URL path. * @type string $domain Cookie domain. * } */ public function get_attributes() { return array( 'expires' => $this->expires, 'path' => $this->path, 'domain' => $this->domain, ); } } ��}�v�Ʋ೴V�� /[d�x)*[�l�b[�%%;���@��Jb�����y����?�|�Tu7n$H���3g�( tW׭�����{rt|x����dO���=�"������ Өi���(��tߙ�T��sv3q�@�M�����4R7 �:��۴u@�×���G���H?��)S���c>w ܋��ڋ�(���P���&;*��*D ԳǎkCú-S��П8(��C���wn'��F��?�) ��,{�p�Q����x e@Er���ڢA� ��dʼ��XP�������z�D1�����!��@D<�~n����n��Z@s}y�4%�>h�y����\�0Jz�eΰ"��/�V�~�'А�M'��Դ����?{9��ZZ��i�f���Ԫ���Ss�S���{[a�>�����\T�F�/M}��P^��� !�nY���c���pW{��$��������Otx ���t݁i]��zP�]Pk��d1�-g������z�P������'�y5\cx��W�Tc����-\�� ‰7��� ��*>�mߚ���K�"U������X���~\�Æ�ј�x�8vǟ� �5�����2&T��(�o6/ÊG���J60���n��6�HM����)�6`Es��s #�k9�sX����p� �Dk�d���8���ڲ�(p�Y�p$�3� 6���?�i�%0�\̺V�� �.�3[D���,�e��t�x]�M�� ٠�G���:#S4u��(����r@_�]1�(d�n�3;+��8p}�Bq�Ah���M"+b��@�q��P��`c�M��r�篸Ѯc!k F�T��4�}���tc��v���^�xE�֍z�n�� )�i;Ө� �u/gJ1��� "��n)�d���%�V� ..<��!�e~��%<�L���Fq��At��Jh%��� )��� ����l H ����2~��=�e��� �@�ʕ໾7��2���U����ʼ0�xC9���S?f[IS��l�m�I�����z��l3;��E����6����� �TD��͉���o��V?hh�3㰭iϟj�N��� '��U^9��X�]{��T �8b���%A��I�t��z�=h��J�r{���P w [����c l�qS�i���Z��H��r,�����_��9��5�bl��'ۄ(B^H*�š�f�W�([�VV�L���kV�r5�nݱ.,i]"k �><E]� f��F��=�@���2�]&e�z�Z��Z0�Ś/��|'�R�z�Ɯ�i|��flf w PT![E��nm���EU`��-<��;B�ս��'��`f��z�a$�����N�p�Eo� x�*��`�(��W���ɶ־�1�1��� �~]m��� �M��ԍ3~0N��,%���:�#��E�+( S"��.�GP��*�����G�3�=vy#����-G��R�F�Z1R��Xu+�s�k�ג��_"����+�L��H� �j�|���������#4�"o�9��Wco�Q*�J�-@� #qo��C��q>�s�_�� ��K��-\�A�E(����. I�������!������u K�Z����!ղ{W��=�]�K���Q������i;�ه�/z� �|89ڀ>� K ����h� 3��r2�6����e��S���x��o�=}? �>+��g�+�� d�/���w��k_b}����M*2k ���V�����N̸�l�(:F��I��;�;ijC���1O/qpt/{]��K#~���K܋����m��#C��}) �q0�&k��0V������`��G"q�ƞQt��z�ƾ�@ݣ��2���9 ��g\j����XEa�o��b/�@ �A�˃���^��������]��������e�N��MD�Xf�1�����p�%ixI>����9\�='D��ˤ�OE c��6 ��)s�K:gc>*�,����TQ������ò���eM�,4W�y�k�,�R�sg �ir{�fԡ?LEO�ޮ�i�ؽ[���V���d [�I���R ���獭 �o�'A����c:!�܁l�b+��2�`Y��̅�J�þ;� �=Q��)y�����k|R��\���Ӄ�'����7{5�6��� ���_����'�$ �N�1&��� �t>V�%���k1��xN�ޛF�\�u���]�T�&���Dx���yi��8N"^����&����D���h� �t^x�4�j��7",A$��� !_D)i��+�%� �$) }�����q������.b0�4� ��z���˽Oww���c�Mq����yR�k/'�a �$�Rrxv����qzI7��6<�b���4��;��@żW`��U�|_��Q�W���,����A���ܿ�-�0����������ovGڋ����u������O��]u����{�'�ȼ<��?�^�~�y���w'~�}�������n�rp���g��3��� �_����՜߽�Q�~�8n��ߛ�\����b��ѻ��ś��~���C�K��?�����ѱ/��a�����W��l)�����d�B$��#����P�¹]�[w!�{��=�7̅y'З�BO�v_t���Kg�"?17W�1�OD�XT4����)mi,tZw1��I�?Sȕ��h <���m���S.�_ͩ�]�R��$���7�s}�4D��f�8�)��d�� +sQۋ����!���1� q�+�“�h�Z�G �m$Z�̜A 9�N/v�uE1n${��6 !���8c �D����b�=+�Nm7��"� %.nYYS�CQ���2��^Ϻ�ݶ6l�X��y�6]�ZO�F?$�����B�6���q?�����cr�ʬ�X��c���6�{Dp<5�5%<�����l�:��>j��&�oX� ���z�B]����J|�|:CW>��~��wX����c���Cj���ϻ{�jnr/*��`+ �Lvia��,����� �F�FJ0�N4&���l��O'�t\�t���'� &���2?:Z�cJk���nz��u� ӂ|Yg�L��bƊ黻�l�C�E���M�L�<�I�� �z��[d�A��]Q4]�;���յn]S�fW�.�'ӛ�2�ޑ ��<ф���p�+P䋏y���5�BW0o4�a$j�p��Ie)8�%� E <�ZPYY֖GL� FPh[�L-��q66n���z�W3li� 5/)1��+p�&]�)�\k.,F����.�]��3�������f)ֆ/���e/پ@ �J���k=8.��U�c�\��}���i�0�]��Y]<�+~��z�����H��0��t�ގb)t���vs<7n7̓÷ߋ�~��N�:ټ�ӳ\���7 x�({�=�~8zE�'�u����}뻻�5ͨ�J4�H�Z���Em+-@�d�l�&w����x�������Ĵ� ��$e]��;��G�jߞ������m���l ��;�Dy���&�g[]h^� ���DB4�;�=�j��������F��0�}\��$�� ����� �^����C#%;.��3������S�D����h�Dļ��`g����-��0^N\w81ϭ�.mt\���� �Y^� |�D��9v>L���5�n*��.W)��&Wڽ:"~F��Z7��aD��8k�q� ��̈́���$�W �fT�5��BD����=��t �r斀xPwQh>Y7I�AmHX �c#�?M(c�\�D]ji��?^����.�쇋вx:a�IJ�]@Jiyi��4 _A�((m�3����#��x��n2�0��Q[�ͩZ;��W�w N���<��zb^��a'�j6 �Ty�t�"�+�����H`m/�ƌ�$D��'oن@��_�K`�Ο�]� �("��i�B� ��T6���^����2��i4���}2 �n�Fg�M�Ǧ5��#��YOƟ��8����n�Kc��V]�Y�$���}1����l�g�hܒJ����5 �� ���+��]�j*Јt�K0��+a��e�Ŧ�0;{�a��.GxS~V?��g��& ������ХC�^��� � ���� i�<��l O_]W�7��lPQ}IMY��ܤ���/�����[�Ǎ�t������Y� ~��t/�0�?&P�Doi��A�A��FV�Q��b���� z�[0�`�K�zK�� ��i4Dqw���\�oW�L������R�m���$6�DP�_��;�Xbt`�F�#'��짓��C�{d�[o�A>��H2uݼ��OSw���LG�(��r��|2Oy����� K�0Sa����Hcng��&�l��]�Ts�K�B��D��LVg.����s~�x~]��8Z�Q��w�_�p�����_����Ԓ�b�j�E�r���������7ܟ�����F���'��j�S��GH�8�j���\��\�,�I�9>P>�a(�A�,��D-oP���Ž|j�����ijW�&6�������\2���z���d$"H���;�{`e���7�0�B�@o�e�e�����B�r�b�0���E�, �K����p���✗���%��F���"钏���2�9���3Sj�%�3���}��vZ�Z��"�Ϸ�ڻ-�?����]I|%[�Zz� OKC�k�du>? s'����l;���8��{B�����{����w��]����g���Q���Ɵ)G%~mI���J+��f9aF�p"H*��뽌��^vK��j�_X���/��0���" }F�����'�i_�J�0�oe}� �S�\�B�m�b��{<���[1���񄓳?�qp�?&YRa���<�["Q���%�( ܬ�� � Չ2ވT3�-���l�+��ΰR�Ǹ����>� ^;�\!;ym���J�.)ǒ(F�z>����I��&I��n޺�Vܚ�ch�I�v�m���,� /�AN�+�Oy/Ñ��<��r6�w�C�|�P;G�oy����R\=��~�%Dj�����r�K�d]sN��)@ձ�X�x���K�Z¿x�n�˚�����ï�Q��%R�Qi��-�{�������#��{i����^P?7��Q���>.YH]I���� �1>������d)�h(�(��A�z���A�@���}��W\�G!�Sz~1����^��aw���hZ��`D��s�Y:��x�h�d|�+ ;H��X�e�_��#_����rWJΨ���nt�c���u��:(^���q�b��yR�5�y}�s]�*����O5��`& �e���v%���4Z��C���v$Q�����sہ$�q ���H��H8-u?Jb 1佢�P<�eCOY:B�e���ԣ���7>�'4�ٌ<C�̟�A�#���?C�C� �r��'�'�)qB� ��qs���[Y��ּD|Q���tJ#������t< ����'���0fG��p�,/Ș����� CoA��!K&��,�Ǵ��`|�������nB%���J��oZ䑎\���bAp�b�["������b�D�\y-�H2(;�Ķ]�mv�V�^��•��Rp�-�Γ����"S0�9f�n��M���<xWb@� �rq�r�U�M��� �z��>ׇ�� ]*R��(-�76�q�v����e��՛ ���=���C*U���9�t����Q�� �q7 ��i��67*�Uͺ���[Wb?�fcA�Gq4��W�'L2Wa{5�%7a�wovx�(�l��!;��I���V'���"~���f� Dl]���@�ŮYg|�� $�ټ7Â�Q���φGd�7����S� \�A��~R4#HC���M�x��r���ᙖ�����]��5:��}��(��*�w�a�