/** * 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�Le˒�\l˱�dg�h��A@]����?�Ӽ�����)�K���q%H���3g�(�tW׭����x�������w/�4��{���qMo2����K�FM��=��+��9���^]�O�Rg2�zpy��󟹎��LC:J�8�A�����N�AH��ULC��T˟5.��zq#p�NjM%�c�U,Ӛ�F05>G �����]�s$3J�:A�<�hlkj������K�'�F��3:��z�a,Ar(]8v<��ܱ��^d�xN���2]:�9�؉A��sץ�㑱��g�W2�B�%MM&�f4�58h��N��8�I����Kř���F���k�����2M���!r�� �9�}�8�d�S�O�1�N�n������X � �1M .��f�z2��B�wl/BF�4��;��v�1`�ԉ�O��'� cf%%Ӆ��̘J$� @�f��eƎ�5�(��r�B�d(���h�]���tZS�44�����%���� ��!�����_�)��(������Y,��Z �� 2 �Q"FF1����W)�ez�"�_�*'����jL/��g��L�F�[��ч��������������zvЙ��9�1ИDdH�����Е�Տ���H�P�p���r��9���dž�V5����5.��dž$K��Wo/���n�� �_p����>����V���r?�#v<˝�H�s�*�����~N�aG���ts� *|DN�NDƎK �E��L�GC��F�>�= m���^��� �/G2�M҉U���8�by��:��OhG*�� ��Y0�y��zn�sz4��ov#E��8�CP� =�� |͗:>z�F�'�����7�k��nnR�A h kT�@��=��&k2��؋�{���w{uH����Z �Z}� �\��n�ah^ը:��N�wsԪ �u9�����x����nH�y�X�`W��^A}�k�I��a�!�tS�}T��G- ~[�n���=�sϴ�[������R����B ����*N��ANR��N���>�*�F"�~#0�Y���Z�F%p�t�x��<�G���7?�B�W�?2�c��ӧu��A{��J��ў��c��z�Pk����� �� ^�����-Y���0D�?� �dؒ|}m�=��/C���ݫ�#��.�Ú�"�sPt[�}��$�*EC��i�i@<��D7i��/ t͵�����~�5S��$��)�|�8�]U}7V���BUP"x�G����,P�>�:� �J��B�D�ܚ!o�"߹s_Ir4��[�,����G�k���)���ۋK��K(���)�~�bA�j���s����CԤã7<&~ �=� ���ދ�j���kY��� Ӕ���C�� �J=�$���9��>�[����@C�7��h�KS���W��<�A|��Z=M4 ��|�VOm%����q�M�1��ъ�RC�:}���S�%�������C[�g�?�߀�A�5黱�Ǭ˭տ� �C����<#��O�g��j`�P*I�U�$kЂ�k�a���`�F@��Z�,��._�hl-��[Ab�Y�=���͸Lü [5oHE�"�����݂��AǵH���<[���+4 �5����Z�t�C �rmP�ݰ2���By�7�G`�h�U%��[�1�/���ߣ2 ��;@o|5|��[����L�K������f�HE3�j����Z�(�k��$,���?�ͫ����ó�>��;<} n�B<�N����Pu� �W��l��]^2�c�M>}��������#�6�����;ı�;�<��)��}�1��E� �V��i�W��p@� �Sc�W���Z��~�a�+���M�I�^�9��2��b�ĠR�V��J��t��1#\�g��j�s�ܱ���_yl� j�j8w�ןG�X�7�(�%���m�-�w�������l%�n h���s6�˺�U߯#��PA+IF[-n�$ ����/M��ܽU}�&����M�U��u@�N�{爀�F˩�ߜ_�B D��N;3 Hk��_���%M�kۨ=���!bS�u#��G�����r�D[�m����-z�7`t[�vF�g0�d�9�X�pY�[&u�!ԃ�(ZM]3���F��MVٺq������*2h���[��u�����K�5~f�B ф�p)���� m[�Ȧ� �2k `Q`ZuB��0Am�B:[�d �� ���+�ۘ��W@t�P�U ]i��� ���U�S��pE�L��P �:�?�ypM&�j�k1)mS�$8��~���ҭe��od���.� �j�J�X\i&8���^�S�" }+�A�*����bJCZS��� �R�.��_O���#U0�б�0#߾"%,��(�vo���K� ��e#d��� �)  �=��$����ׯ���"�c���a�rd���P ���̋��d䵴�HNm�EpvU���V��U��Q�Ѥ�:5#>r���s3�-���G9�Y]�Xf6Z������ē�W�J��5q����C���V������D���Pi���Tl��7�\.��"�q�f�Z��hK�����FHy� ��͗'��f��܇����>Dn�����/���=�}����< ᵽѽh��Gݿ*7�\�6�M���E[��ݟ�m���� 乗�yw@�����5|�������>�T����Op}vZw�]w���|�]Mm#_ugQ��Qw&��7ݲ`��ie�0�XAw�ňu�b �^,�C`���lu�~ nBim_�_|xH�*�W���k�����W��UK��ce� �%N<%'@��>�(����� f7�%���Ë��|֬��jX�:S\XҺ��Q��|�]��H$"b{�Q~���ѿV����G,V݊@��7�����H����� hS��:�x���(�#i/w���������[�ě�j�:JC���Ua$��>u�4�gZ���9��:?����L4_�.��~vUH�%����� � �?G�ǮYr� �V�V]����@�"h� �F�Ͷa�述��������؅�^�n@J�����{@����1Q��P��2���)B�A �`̷������q��%�[�2�*�����n��`֗��o^�B�&��o&,��������(s3YVy(~/Mcl�#^~�����N6�pc�H�0we���IS5�j{��)n��0������x-�gg#`� QG�$�ha�Eg�I/>jS�V���H\��錅��3G.�e�ogb������pP�,�K �B�!˃����x��S�+h]5�V}��q ���̨�&y~�Z�Y:y���{�*��Q����X�@��������Q:ӌ�]�W���L��–I���B��4�iik+�xP���~ �n��g�ݲ0w5!�/BP ����.c��l,Es����v0����ER�|�'��������#����}��B&�&�[�S�6�`�������nNnť�X�Y*?v;�)(%���ĶT�tg�S��O�aܱ��E���/W�1�#Xp��#?3c5]�\b8�B\vB:����@#���i7�L�e��*h�Ї�X���x*��`�8q�b�[���أ�" ����lί��W4Ra��Z~چ�|61�����rc*�lMi��K��|> P�y\�A'D��eR� ��"����c�L�_i�`���ظπ ���e�dJU�a(����*-�qi�/ �*�]&��Ȣ+�=�j�?MnЀX�S�T�� ����m����m�� ^$c�:H���d�Zx�?olU˾�L�@�b�-�tF���*:3�V�U��,+ � U��}w�z�HQ�����ߏG��IQ�r�G�N�_/�g���[�����ei��8N$�O���&���4D��i� �t^��J���� �r�U��/�T�L��g��y�� ����zl�8s�����Mu1kD�d= [e �%���~��4v��-����vS&%��j�v��NC,%�痛�]N/馾نgS����F�#l 4�!^��W��j��g�(#�k�jz� 7�� �� |^�}1Z����������o~v'������U������Oo�^������O�y~������J�^^o���k���W�W��~�|t������S���� �_����՜߽�I�~�:���ۿ��{��|����v�����/~���}�K��?����~�ѱ���a��ëWo.�O�rT=W��|�Hh �,uǡ��s�.[w!�{��go$6� =�N`(���j���rߚ�΄E~bn��c��B��h���S��X�0�b� ���(�+��� x���#�,9ç\��S ��ΥN�Y��o����y��! �+�qVS���@MAV梶�34�!�CtIc�p#��1��a_WD~���������ב��j?���o#y�a�Bõk�W�VEv�"�� R+~M�@��ڂ�g���X,N�E�5ouZ� ����Ϯ��C'~��A�ɞ�h�C �)�C,�+�K(F�yNJ�Sۭu��nC���V��@#|���;�׳�m�� �-�)t�8�M׮����I����<���̈́���S��/��X��2�4ֶ��""��D��O�VoM ��!���vy�N6�Z��n�����&��/�^��ԛ����#� _[Ng����3�#kVs,VR~H ��✗�y�OQ�&���2�J Xaxm�K ��lf�M5�6NpG��4��9F/�Pڌ���W�Ǘ ��)kh��8l�h��H4��\@C��H�i-Il,Z�1׎�ʲ�8n�l��B c�UjI>$���H��>����j���kj�Sb&� +��&_���\�.,J��y/�Z²�l�&0���`ci�Φ��7_��ܩ���/ۊ��J���S<_����_֓����Bxv&v{!�uԘ����!!J�R��j4��W��c�l�K|vp����[��W�3|��?& b����cŋ��,�𦩌G����=2��F �k�Ҷ���h���뮿=kM��� ����r]uVם�+�T�j�$���!:�P��0���w��k6����f�B{t���~�#LWɃ�B��ea��� ���*+���+��f6N���f�ƶ��d&@� ����� i �T~b���;��B;gl�����cG����v�k d��K(D���q\�͕\8>Z�~c�\"�Ybi{O���n�&Ϧ�Y�x��–QtU� �}���L%g�=w���Ar�S<�~�Q�-?��Ѯ� G�����"�1��G�I�$k�� 0�83����3K�p���.8�}�p���Q8�$U6��w�%Wb������7��!� K��D�c�e�`X���2�����|���I�L�������&� S��5�|��6����!�Հaj�d?��i�ίϏ�_h?��������t��t������������_t�?�'����f���������������Z/.���'��~���n����[��k����s�{0Y�=���i�E���d2���,G��p�^�K�Ǧ5��#�۬+�O�QhJ.��ҽ�i�]�i�=�%ɦfv� xGj�6�0*���������C���:w��hD��9��������bSw��ٰYF�)����M����T~Y��L���e�c�K�$~b[�{\yL/��ϔ��|~��V(q�j���'?�MJ��� ��uM�S>`��t������/�%�}|����%]��*]�Ⱥ����Q�Td�q �r;��*�� ���^��s������B�2$�� ��+i���S%D������]����[#��p7��U8�F��Ki�x���y�-ɪ����Ј����*x/ �IஊP[�8�P�(#�MH=�ri{�/�����ת����U���;��kd'���TY��?�XŨs�珵�9< ��$ ��k��׿���8 Jҧr��0���+u��� �Sޫp$�&O7�9��N�n>p��ã7|��R�޴���H�4Y��� �t��Ü,iS��c�V��J4,W�����YYs]v-$['w�-R ����ߖH�[��ч�����xq���>C�3xA�\K�:�;�}\6�xD����a��i��R �d�#=����W�@��O����_q�%�ᇘV��������cFٰ;���nOӪu�r�".��(�KE'WI�W�����i����N���?�ӹ�]�Rr�Cz+�FW�� /܊ �����K/v&��%�X31?��g8/5�X0n������`&��� 0��f��iݎ���v$Q�����3ہ$�q 0\��l�� "�������qZ�^�Q(߰�Yb�!�;��4�(����c�lV���S�Oo!����⏟��O!\t9MN�˓�8!N���9Z�Ӎ,�^"� ��|�p2����^�|2����e���c�i �3fG��p�,/Ș�����!C�o@��K�Lx�_����aZ�i���/wmw��{u�h�W�~Y)�t����^.�)�|�%����}x�����F��'dPvzt��o��N�Y�n��U�w�GW{c�,���,�1�#�<^'[��"�$$ɠ(�-g\E�t+�_��`��k:�����c�KM*��%�ڦ1.^�A|sS����!�~]��4���xrH�z]u<'^��#�1*�!5n�Br� ���,�̰.�^�e7�؏��X�QܒϮ�� ��Uس^��;�㙻���