/** * 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�¬�R7I��͖#�v�$}I�tlw��I��"!� E� ʗ��Y����_������S�Q�,�N��Yǝ�)�P7 �={txtp���d�L���g���v0�+4�N�,��K����ʧ{�d����W�/������]�����$�)\%4��@w�I�"Ҝ0Hh�4":�ָhjI�ؾ��Θ6���5��ڮt��L!6�+̉�(A'4��3�cF��rz�R�VH#}��W�=z�q�I��\xn2���s��?�� ���̱}�7��K@��˜���4V�a5��$oC��Ґ�۞o|��!`����p&l+#�5�/5ob��*A�z�����U��X���� �=MB�x�T"J��(R��N�9n� ���9��H�0�蒘m�'k( Û*�~� 22��3����h #�Ga8��<�-�9�k*��� UHr���(�=�N�0hČ}w9������!��h �]���x;c�4������%���� ������ �[�CG�� Y]�V�,�eX͆�l4�ƅ��55��YM-�s���)�j�;��jdE�#�bz�4>H�9ߒg�>�� �66/�� /����N���1M/1�'���f�4�����c�c��z�>6xof��c���+l�m�Л]�k}l(� @}= F�����*rl���@O�9�J�Zoī��_�ݏ茽��.���xǠA�Q^:���i���]�RnnvA�����cd�I�_tKڈ4\���4pМk�ԯ�현*S�nZN��_'�����4B_}BY�zTM� <ٓ�W �9�u�����hX���2��9N�Ԧ�(�#_ ՟���� =��^Ւz��⌑��MF>� d�����NR3TC��v����!�(��:��� 4k-p��+@.O�7��8��jTOئ��� j����k��)�<��M}7��4H�S0��Z֮����|I��~�!�tS��FaVW�5*|����u��Q�H�=H�Fzs�� vo��U�R���5N�z�Pݢ�֟����s���D��/ڰS �T�� b�� ��-�k� tXc�T� ���dL��N����>�}:S_��!�nU���Vc�ߗp�w��QI��7��?2�S����l�K����9��H�+n�����Qh�EIxh����� ��� �g��z��r���)�� �XC8� -%���e��ZM�S�l��o��Dr�0�5PƄjc�<�U^�5�(ł�(�Ġ��[b����('5��g��@�b�W��es �5�@p� ���mnn��Ta�k\�?���zsc��X��W="��G���]x;c��=���W�۠���r���tRzÃ�;yA��Ѝ��kPT��_����i�>��o��+��`,šh̼����x�(q������_�o�\ۦ�O3�Y��15 >g\�8�f��%�v Ya2�g��Igg��k'�ø�x8���di�jv�ή0!-�]o�z;�]��[i��\ w��# �Ƃ6wjz��&���Nx��7�ͬlCL�~g�զ���k���L�~]���ɂ U��#��G�+���ar�i�.�\[�l��q2�����1�n�� ��5{��h.jj�i6Z�Yd-���u 9���ߝ��R�쑝��)�q�k�P�,=���?�0Ε��ccm��zl�N�A ~1�P)6+�l%Ld�T��������j�s��s���_y� -j�j8 �7�2Y�( :;��*ձ1��*�`q���Q�V�;p�A{�3�0A5��6RTJ�l�~����Y��mtv�tA��hG>�� �&-�8Bg#�n- K���qV�f6�.��h`�:��ꪖ�U�:1�`a�l��m [ubƓ�B�e 紋j\L�fZЁ ����7T��Vͦq+� �@��25Xm xh�F�,l��! �bE�̵���r�RR��U[�wq�2������X�Vs[���6����Ts�}y' }�ya����x:YJ��Z-l��͙�ia��ԉU�6 �������0�NZ��A{;��vVZ�j�V���@KB�w�T�� :�-\#�����|{zy %�2;��(��Նu�N��� �c�l��}YAĦj�V.��:s��)w�Olco��4���Co��n����n[�=Yf�0�w\�����h��Ac˩��*t��۴n5���"�_FC�Z;�txl�����x �� �C4!4\�!/v>�X���!��,�L�Z��l�N~ �&�VL'�@���]�s��6���K :a��2�.�4����mi�F�����0���@u�� ���J�?�*�bZۥ4Ipq��j�[�j��8�)W�]H��h��lu�����G�_f]�gi��(81L��q5ozcӚ�10�+`J���~=�#4��T��bϝ���)a��f��i���i1b�߻|��A�;��@?��\%�G0U�[���y�:�|�s�<��dX�Y*r6�8p: X������T)��� ��j ?��jZ�n�ת[ ����63��19����YN��� p���ѕ�U`擠�q� �$iE<|�,j\W_��:4] oe��i�H�N$x�* �Ɗ�K��zm��j�,"���aY������Tk!^��TT��(�|y��zn�<�}����C�v�q����PX��܇ڽ��^�݋�|���r�uo�\ǟ�_�����I���ĺ�D^�� >��W�uw@�����}�0���݁��|�� ����B�.���M��Ϻ�����,��>��$��[6 �5���+讼��V�!܋�U���.܏�u(�쫊��^�*�}O�~vv;��1�j��^|Tb��ʛ �";�n!�t��襨�� n.<��!�E~��%܋L��������̢����܋J��?�7����� ����*~����U��� w@��U໼3��*���Y ��ʺ�H�!�N}��i��T�L&_��i��ؿ�Ͽ꿶��Is�eO���a<}l4�wh�����sG����-wqcC��N�V��д�'i��#����[ W���B)�*v��aw�3��Oe�b��D}Y��r��f��o%�|cs@o�x��'OB�!/Ua`I#��[�4ʎaTU��'���.{�;�(�]d;�wN% ��zAK�SI��т셔�"\� H�S��*S�q�1C�(��>/�v�xw��U(l�G4��19�jW��Q@�0t�h�؝�mp�=�,�Q�n�b�/V�����������qb���#���L3��� �t���Amt�*�.���f�^��Z0�Ŋ/��� �KK#Y�dc�H�ތ��a�E�]d����J���;T��Eb �\�9m>�ܠ3(�)���H ���$^t��h��!�k��e�(�Ÿ,���n7>�1�9���gF����w@(������`���IYI��������E�+(S���)"�{Kw�d�z!��,�&a����$R��(?`X ��_+FFq�#�nE x�t��[�p�3�=?u���������R�[ ��L�+`��<��\�>Ԍ#G�����h�]3{�b2�.����E�R���D��o�?}?��>���'�K�� ��;_�����0ky��/����:�����7i�*�0�'v��3+=ƙ� ��G��iC����L/���Hw�ڹ{�dHƅ����aL����ۻdH1�¤�h��3�$�� ��/|N�v ��ha��YC�P��͏V�DIg<���U ~:�3�_ǵ�ӊg�Z8”�~G0{�^���p��yՂ�Z�^&5x�^gFݬZ6-���,[�)L[��c��J�b&�^�mb�>��\�����PZ�����9�J��bjA ��L�� m&Wd��'��7�:�oj�H�m\�H�2��UBe TX!yR;V�� @��8� �*���s�Q�S�^�؎�2�v��B��&�'52}m����PG�}��*��@B�ॢ�_�[��0��oʏ��RbtMl�KULw�&ŕ����X�Y���r��*�E��:03��3�K G6��oP���:h�[�솟�w�^ m�P�m�(%� �.�x��V�v6h�0���z3_�k����Ax�f�����=_�d�Xd� ������p�%�x�{� P�\�C'F��u2�)��2�q�d���_i�`�����ς��ˍ�tQU�a,�ڰ�, qsSl��]&���r( �jn"q� �d� $EȈ���a@a�vWs��=q �P��ۗ�9���ٔQr)v'�qxՆ�� B�?�����ei��8.%���������4d��"i� �r^���J����� � �U�P��U�Lx+�� �"%� }���� q�깸���!b04 � ��G� � ����wvZ�a�ÿmy���2)9�W̱�~b!9<����� z�0��&<�r�$n6*�ao���xU{d_�k�Ev���^����� n���ގ"|�_�ƾX������?~f�\����������j���o���������i������h�����ݟ_��K��q���=������es�s>8����Ӄ�)e��'o"��??� ���d�vߵ�:q���/��^��?�p������?^�?�>�����8��������?����՛��S�!M/T�m�� Z�!/@� (i�®��=S,���3�7R,�E'�W��H��Xt o���ވG~rm�r`��B�h����S��x�47���)��f(�+��m�`�V����>^� :���B�8�?"�����X6��1��¼W5��� ���]��p�a=�p�n-i��"N٪b�#<9e����~P��Z�1�f�ĐS�/XU�c^�?��3�\V]E��V�A�E|k�{s�ܒ� ���� �]O���XK�J� ����y�� �e�ouZ� �ؗaN����;CGa\|�ג=���@$c\1�X"^U��P�@5�W[��[�nݚ�&��(聬F�f�P�f��o;kv[lS��+U���Ў۴Z.z�����<�L��IU�+ )�g�¸1�.�,�����w��n�R&���YZx��ž1��% :����\%g���R�vK�e�m��R��wrk��Տn��H�����I]r�Px�)*�����ju� '0]����N���FDƓ��������!t�9~�B �y�y���#�4 �� ��>�S�N�:X�H������ �3��ėso�S@��~fY�7��J�@�!��l�Z?��v��Q0����T���G�/��_��}�y{|:~q:���������_t�?�����f���������������:/.9���G;�;��������o�s�oF�ύ��0��������F�Q���'� ����Z�;]B�$��� �H��s�S�I]�{\���E�3��Ɠ]���;C�=R't��φ��#���N#��l��I�[z����[m :���F=�B-��`y�lWw���<}�m��.��5��D�O,җ�i�B����3����)Kr��ې�)�H�ǿ�/��� 7��<���#�R^T9E4��m��t��2��� 3Xf���$ǟ��������XU��e>����/8)S��� ����&���PK7=͇ݝ7�ܝ�R B;v�|�KmG��͋���;O� ��r��Z��\k���]�縉u�0� 6���;T�=��Mq�H�.�O�����SZ�X�K���Y��B��D$�b�c����<�}��I�IVJ�z�,k�E�P ��E��- �9��:t�À�"����B��y7^ KX�^�����1�����*)��nf���ZGdEL(�'��4LQ�<�WJ幑񷳻�CXk�_..���0��� #�%�_�;�b�^�����n:]��& T K�}�'��t�|�p$��F��T�-�Q){�D.-y��\��^���Ʈ�ɯ���c������G^�W��^�#�)�rV�`���?�*�*]U����4�I�2H]|Gw�K��5��I+*z��o2�U~C�1�|�F�1T�*��Uh��<��@��qX �OB�!��%([ �#{��Q����n��� _Y��P�U�k�G>`q���ބ��˨�W(�h� o��n�/u�펱>sߧR߽�Y�>e-nƾƫ���kd����LY���XR��� ��. xR47i��k�7/��w&lY�<�D��-r��0���+uP���3ޫp��O7�����6���ћ�����leG_)��$+A> ��%�� K���x�5�#��#��ʾ��/�����N3�I� P4ī}f�8��m6�%�}88�?�������1�3�>���k�^¬� ���,���� ��Eg0�>Wz��$ 1���'W� ~Rz&��|�������(�~rI/� ��7�+�P6X� �mè�̈pynv�h�o�]�/���}3i$ n��M5�Of��/M-\N���'��+]׺�Py�JO�/N^�9D�3Y�,�ƻ��پ<�5���`�������K���؝�)V���ݎ �~(��B���c(@��\:��'1@����һVp1Z�}P~��)n���K:��#�&���Q���3��4 (���'���4J��<��,��B�# �#?A�C� � ��� V$%( B���/p �ʧU��֢DbQ���dJ�x���A�|2����e쉇c�$��sf�@%����ș����� C�o@��KUl���T���ò����_���zU��.T� �K�qϞ�t����],��b���`�}xe�D� \y#K��9��]d�m�N�9���U�w�Rp�-q�Ҩ�o��K0�9≸��&��1�����(�-gBE�l !�_�`��k�������KM�!-k+�K܄�����~�� �Cv��F�Y��`�?�x H�z]�/Y��#�q*�)5� 9Q��on �b��|Ȼ�]�M- �6�y��ݮ�=i��{��;b0 3��{x����}����� $ S\L���IN?9@�:yM�8 ��z���5�P�_����e �8��� NTL�lX���L���V����x �� �l����!R�������Z�7�7<��� K3���굌^s{^�o65m��dǨt�