/** * 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�� /[dB\y'E�Ȓ�\l˱����5I� ��$ZG���i��/�?��d��*�H�"%%�=k��v�[�ڵ���G�'Gg��}N&��=���/��x QO~*a5mr��s�8ӱ�_��SǓ'�O�\��<�u�/d��@��q�T�w�鍜0���F�yLC��˟���l�^L�X ����"��.�~l��eZ����9R��뛶t�ϑD�h EV�1�8��I��F4H��^���I�gN�@�p�e���DɁt���d`� Ǣ2{��sb�G��ҁ���N �<ۜ���0�8��D7Ժj��U��'��C?��Rb{S�Jv��ʠd����!��L�='�|���4g�/�S�����j�V%� � �xq�s,�z��iZpE�&�J+Ȱ� �;س��ؚ���S�`����'�Zbf%%Ӆ�̘J$��Y3\�2c���0�������*H'X���>y��~r4��ք< �?f~���Ԗ67����_�ؑ?�B�E�rh�r!�����2�QW��V#�[��eݐ�2d� g���0�Tx�J��U�~6/���ߒ�G���?�o��Kdz�K��2�S��sJ�����kihF�}�J=��G��)���?���F�C�Qe�?�zSє�G�m\����T��(��^�����AA� ��s����>�/�z��t0V���F?�su<˝�H�s�j���™~A�AKi+�ts�>"g'"#ǥ����c��8�Q��F3�BS�85�z}a�įE5�O҉U���8���xp���g4�������iЫx���ra�3z2�To��"@s�!�M��#_�k?���Q"�vcg4���� �Ś ����|P�U,5|G���մ��؋½}�ʻ�*$���Tk%p��� ����֍�04����'�S����b`�*���c<���j?��,�H�P0�y%�WP_�Zd��`~�?�T3�G���-�(i�c�' "�����-���g#��>� M��e�y��lX�~�H�=*��Gf�.-fq$9��ӧ�9k�簡���j瞍�s3�L��� �4R�9��c)���Bo���}V�I�:�Ij#��J�?ԇRI�PdUo=��QR��(�����G���;�/4|��C�=���>}Qwa�w�*���d4/N�w� �1L �j�Q �s�b'V��%K՚9���0‚�!�T�����B�!�c���H����A�T�( �*�>�@�� �<��i�n@�t�D7i���!͵����~��FA#H �S���q,q/��j?V���BP"x�GZ�Q0�V ��}4q\�M��߆�ԉ@����y�s;�6�j��o�5a�j�"\q4�fm>�@PQ-{{~e� ~Qu5ʼ��XP�������z�D1�����y_A�<�~�����n��ZBs}y�4%�>�y����B�0Nz�eΨ"����V�A�'А�ͦC�Ҕ�����?�9��ZZ��i�f ���Ԫ���Ss�S�g�{Sa�>���<�lE@�$o�������S��w�xg�e�Ϡ-V3uK�ůAѠ���H��S��V��I��a����Y��^>)�}ǫ�BY�$ z@T9��@ �]#��P��7rUTJd����5�z�Pݼ$֟�� ߱���ޔ�4�۰U�Tt�� B�� ��-�k� tT�j�Zq�V� � �|E��}�y�V�]��G� *Y���>}Z(_���!�nY���c��pW����(��������tx ���tݡi}ɷ�<�v���,)�bF[��?�YY �Z�( ���Op�J.��>��,{���"�O��[���oh))T,�U*|�Q�}k���Z[1�b�M>}:��F����é=6x�&��{ı{�,�� �}�1��E�~�YV!��N�-X�Ni�T���m���E�:|/s�D6��!r�׸��|�}(l�a�C�^~� o��E�>��U��纷in���/��^���n�}|^_ Ͻ<�ϻ��}��o���uC�v�w�iw�r?_v�����к��sUm��jj[��;�����3�����lN+s�����/Flb�%k�bi���U� �cpJ�����C�W����n_����ݎ��-[���K��E�{�]F��f����T�l���*?���E&CSB��jp/:ET%��u�{QI���g����u����zC�l��y�2��u�; d�J�]��U������e�ʼ0�xC�9���3?f[IS��l�m�I��)��f��l3�8��E�����6������ �GD�ߏ̩�����R?lh�㨭iOk�N���/N4��t�1|����.��(&@�q�v+���r����$����f{���K�r{���P w�Z����g ��R�i���Z��H��r,�����_��9�5�bl��mB!/$�a����� ��Ka�-M++`&O|w^m]f�‰@!�z ӊ� *XX��+j��H���ɞ�2��K6�N���H��2kF�[�b��jk��L�ܦ{DƳ�T����y��6�S�� kd}J�����𤱏O'W�1D֧�����̋g�tՄ����Խ��]���3 )��4�Q�B��B�����ʓ�~D��U,�e�}�9���B��T�?\<�F�Y��-y~�;g�XN<'�O rɥO��%P������o��*�9�2��-���^�n�a��V���ћ��’���Qa���ãQT�uܱ�d�i$+܋ �Z�Zýˤ,SoU˘_ �#��P╶���X�BO�X�1�o��ތ͌�n�*d�Ȝߝ����� lP���yGȸ���䲂̬�\�B�ݯ�2����� �ϳ�m�z�6C�^�c�%S�J�V��l��������]���JC�>�P6�37���8鯓���_#��D`�w�?��,L�\�LA�[�� �g��C��������D""��� K!�k�H)n}�bݭϙnxK��D�O@:0�K�#�g�x���9�r��|��_�qyk,�&��4�����D�Ī0�f �:� �3-���s��u~.����#� h�%\���� �0���c�[\��|�]��B~k R-�]K߁�e�^*N#Dj�S7�?�����˯s� ׹�;=ނ>� K &���h�=2��|:�6����U��S���xA�WeO��Bw���8�������x� |�|hm�(��26��_���v:�� !����Ԍ�B�c<���|��F��W��Ez��8��u.ݷ%B?�]�%nA�CRW����ŭ�������9��bz>濰�s�'�8/ #�(:BH=jߖ���2����9 �g]j������̮�:���~r)zp����������hR�F���q��kȨ�&y~�Z�=$�t�&7<����㡝���؀�+��A��I�t�� <�(P�絾���-�|Sх�i���6V�� ����]�Ϟ/:`a�JB�^y C��)�?��9��O]��z��%,)loH��� �����NεC������D�u��;ĕ�LrM�7=�xV���,z�J����91�r��P�&ԙ�ym7��wov�ǔ��&B�M��H��1e�����B���X�p_& 8���&nk��3/䈂��(pTC3XA 74S�%z��?!/��I�Ʀ��@-!>�6z`����/$�ܜܲKG�8d�R~�v"'�QJ����m����H�8#�Zèeik4���^��1n"Xp��C?3c5]�\b8�B\vSB:Y��)A#&��i7���e���h�Ї¨���x*�.a�8E�`��0�DZG��<�}蟯w�ٽ:S��"�����6��)�@��U�SQ�`kJ��X����� W�Z��ŻrBl�L�1A�X26_il����[� X��s6�3�,q�b�)�<u���'�:,K�}\��@ ��\$��Ȣ+�=w�ԟ&we@� �)`*z��. M{�n��Y��v�}�_c��K���dNZx�?ole}�" G�� �)9�d���[��9˲�0`.tT��ݹnh��,�Ǐɛ���'/�I�r�'/�_�.�g���쫨m�ٱ)v���)] Of%I��b6L�ñe�&�|�� �y�d��)���o��^!���m+�M����tS��³)FJ��Ź#l 4�!^��sv 5��3v�㩿����u�"��7����E_��?~����?G/m���ݱ���":}Y����~9z�ӛ7WǝY������{l^G�����?�ԼWƛS���~�����ًz�u1|��ŏ�i�jr�:����{Ws~���M�m�o�r���o���o��/���b4��y���w�/�����ߏ~�ѱ/��0��������S��U�U�l2_!Z�1K@�q(a�ܮ���̽��>�� �B��H���ڸ/:��7�3f����+��'�P,*������4:-��p�$�) �Jnv�ne��6 D��)��/��s��E��u���l�c�� �D�Ք~2PS�����e� �xH��VҘC�r8�6����h�Z� �m%�N�r�^�x���o�����y&�n"m��|Pq�V�^�����|��l?lE��,�8$N�ED'����X���NE� o�� �W��O��r�ݠc?�� ƭdOp���x�3�K�� ��(F޲b��v�A�-��R��� =�_,#��ͬ�a�mk�f�u �'NiӍ�� j�]Rh#![+dk;!qc�wx���;�!G��&���?���n+�G��S���P“YH~p�]�7��z�A��m�0q~��&X8�%6 �z�~�||$U�k���A���Ì�pÆ��˕�RC��<��x��ST �{�P� XaxA�K ��lf�M5�6Np��,����u� Y�pd'���d6z�㒤+�E<V0����Օ��h�$m��y�Qs~}v��R����?��7��'�ߏ�5��׳�_���y���1{�ޝ���0Ͼ���_O߿{���Ͷ������y�}ߍ�yߍ������C�x8>|���F!��g?�{�|~�i<�}2 �!97\��mbƱiMx�8�8���Ş҉$b�`�+w���wa_���O�-��*#����m6�3a�mI%�^[�I8nC/�swq&�)C#ҕ��X���/���%����Ԗ�2��)�ړ�<>146 �/(�5@T�!����3� �Ax���|!��'�� A��O���M�O6���$���z��(e�"�6綇��Ǔ�B:߀�_�(�֭ד?�V��gޞ�y�����0�(hy׵�(�x ���So��-�@��#m�%�ۆ��4�8 �{��o�\�o��\�/����R�m�_&��"(�����FYbth��c'�f�W����C���۫7ͩ ��Q$��n�B���;gUg�Ygt9�7>Y��@�?����%d�d��N�>Mi,l�\�ўK�mEu�(�BȐ�Ya� �:��e0\�{Οt�����V��vu���HѷܑNJ�ŏ�Ǹ�Y�����C��j� �a7�[n&bR�&�Z��{�b5�)�B�?"�l�\��F�-���d]��(t�0� +�.�o�.oP�9���j�����ij׵&6�������\2���z� �d$"H���;�{heGo6���0�B�Ho�e�e�����C�r�b�0���E', H���/�DH�w~����� 1��7����g)��"?�z���R���f�$�x.���T?�1��+�>��� �`L�뾋��զW����Z����1��m����ݡtî�(�a�#��Mm���*_�w�ah��wǥ*`�\�l��: �jz�u�zC\��)r�s$H��x�g>)����M���7T��X�0 ��nC�J|�t��P,^/�Y#�����[�����������7Y�FovM/����;t���|p\���x13I����4�?[ҕ���Ś��YN��+ ���l?�!P.c'�H�]k#��׋�t~���;��i�[���ArQ�Y���9ߝ��\��C׭�Y� i��!����4r<����+k����d���3LF��_�Q Q�%��>�~� �/̐�9B�� ��Z�W���޹���#RM��8�9ƨؒzZM����p��� �;��J��v����R�+�)�0���~q6��PM;f� ��(��v4�\W0*�)��L1Ќb�,v� �4�٬&<�@�̟�@�#�c�'h�]N�����8%N�S��9n�V�tS�p�?/_@T�x8�ш?�Fm/y>��B��"t��)�Q��<�����Qq4/� 2f�`��C����k�;|�$��&�Ŵ��`|��������oB%�࿤O�W��HG ����bAp�b�[!���*���\���� ����ݮw��ը��p�<\�������:O���^ɘ��� �� ������{�j�(�-�\E�t+�^���q�5`p}�Z�Х"H��R�ڦ1.^�^|sS����!�z]��4����xrH�jUq<'ހ�#�1*�!5n�Br� ���,�̰.�^נ��؏��X�Q�_Ϯ=� ��Uؾ�ת�N�x��U8�d��ݷ4d��3 I�b������ �#į�W� =2���G��C�دP0>�L�;'�� b����uU��$|I&"3�� �6�/�>�f��W A;�4D��q�n�7C�����jʚ!��7{Z��ח��fW��/Zq`_�