PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.90
WindPress – Tailwind CSS integration for WordPress v3.2.90
3.2.90 3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 All 144 releases
← All changes | vendor/symfony/polyfill-mbstring/Mbstring.php +128 -53 3.2.833.2.90 View file →
@@ -75,8 +75,9 @@
75 75 private const SIMPLE_CASE_FOLD = [['µ', 'ſ', "ͅ", 'ς', "ϐ", "ϑ", "ϕ", "ϖ", "ϰ", "ϱ", "ϵ", "ẛ", "ι"], ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "ṡ", 'ι']];
76 76 private static $encodingList = ['ASCII', 'UTF-8'];
77 77 private static $language = 'neutral';
78 78 private static $internalEncoding = 'UTF-8';
79 + private static $iconvSupportsIgnore;
79 80 public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
80 81 {
81 82 if (\is_array($s)) {
82 83 $r = [];
@@ -102,22 +103,48 @@
102 103 if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
103 104 $fromEncoding = 'Windows-1252';
104 105 }
105 106 if ('UTF-8' !== $fromEncoding) {
106 - $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
107 + $s = self::iconv($fromEncoding, 'UTF-8', $s);
107 108 }
108 109 return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
109 110 }
110 111 if ('HTML-ENTITIES' === $fromEncoding) {
111 - $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
112 + $decodeControlChars = static function ($m) {
113 + $code = '' !== ($m[2] ?? '') ? hexdec($m[2]) : (int) $m[1];
114 + if ($code < 32 || 127 === $code) {
115 + return \chr($code);
116 + }
117 + if (128 <= $code && $code <= 159) {
118 + return "\xc2" . \chr(0x80 | $code & 0x3f);
119 + }
120 + return $m[0];
121 + };
122 + if (\PHP_VERSION_ID >= 70400) {
123 + $s = html_entity_decode($s, \ENT_QUOTES, 'UTF-8');
124 + // html_entity_decode() leaves numeric entities for C0/C1 control
125 + // characters as-is (HTML spec), but mb_convert_encoding() decodes
126 + // them. Catch what html_entity_decode() missed.
127 + if (\false !== strpos($s, '&#')) {
128 + $s = preg_replace_callback('/&#(?:0*([0-9]++)|[xX]0*([0-9a-fA-F]++));/', $decodeControlChars, $s);
129 + }
130 + } else {
131 + // PHP < 7.4: html_entity_decode() truncates strings at NUL bytes,
132 + // so decode the control character entities first then call
133 + // html_entity_decode() on each NUL-delimited chunk independently.
134 + $s = preg_replace_callback('/&#(?:0*([0-9]++)|[xX]0*([0-9a-fA-F]++));/', $decodeControlChars, $s);
135 + $s = implode("\x00", array_map(static function ($chunk) {
136 + return html_entity_decode($chunk, \ENT_QUOTES, 'UTF-8');
137 + }, explode("\x00", $s)));
138 + }
112 139 $fromEncoding = 'UTF-8';
113 140 }
114 - return iconv($fromEncoding, $toEncoding . '//IGNORE', $s);
141 + return self::iconv($fromEncoding, $toEncoding, $s);
115 142 }
116 143 public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
117 144 {
118 145 $ok = \true;
119 - array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
146 + array_walk_recursive($vars, static function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
120 147 if (\false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
121 148 $ok = \false;
122 149 }
123 150 });
@@ -152,12 +179,12 @@
152 179 $encoding = self::getEncoding($encoding);
153 180 if ('UTF-8' === $encoding) {
154 181 $encoding = null;
155 182 if (!preg_match('//u', $s)) {
156 - $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
183 + $s = @self::iconv('UTF-8', 'UTF-8', $s);
157 184 }
158 185 } else {
159 - $s = iconv($encoding, 'UTF-8//IGNORE', $s);
186 + $s = self::iconv($encoding, 'UTF-8', $s);
160 187 }
161 188 $cnt = floor(\count($convmap) / 4) * 4;
162 189 for ($i = 0; $i < $cnt; $i += 4) {
163 190 // collector_decode_htmlnumericentity ignores $convmap[$i + 3]
@@ -163,9 +190,9 @@
163 190 // collector_decode_htmlnumericentity ignores $convmap[$i + 3]
164 191 $convmap[$i] += $convmap[$i + 2];
165 192 $convmap[$i + 1] += $convmap[$i + 2];
166 193 }
167 - $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
194 + $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))' . (\PHP_VERSION_ID >= 80200 ? '' : '(?!&)') . ';?/', static function (array $m) use ($cnt, $convmap) {
168 195 $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
169 196 for ($i = 0; $i < $cnt; $i += 4) {
170 197 if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
171 198 return self::mb_chr($c - $convmap[$i + 2]);
@@ -175,9 +202,9 @@
175 202 }, $s);
176 203 if (null === $encoding) {
177 204 return $s;
178 205 }
179 - return iconv('UTF-8', $encoding . '//IGNORE', $s);
206 + return self::iconv('UTF-8', $encoding, $s);
180 207 }
181 208 public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = \false)
182 209 {
183 210 if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
@@ -203,12 +230,12 @@
203 230 $encoding = self::getEncoding($encoding);
204 231 if ('UTF-8' === $encoding) {
205 232 $encoding = null;
206 233 if (!preg_match('//u', $s)) {
207 - $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
234 + $s = @self::iconv('UTF-8', 'UTF-8', $s);
208 235 }
209 236 } else {
210 - $s = iconv($encoding, 'UTF-8//IGNORE', $s);
237 + $s = self::iconv($encoding, 'UTF-8', $s);
211 238 }
212 239 static $ulenMask = ["\xc0" => 2, "\xd0" => 2, "\xe0" => 3, "\xf0" => 4];
213 240 $cnt = floor(\count($convmap) / 4) * 4;
214 241 $i = 0;
@@ -221,9 +248,9 @@
221 248 $c = self::mb_ord($uchr);
222 249 for ($j = 0; $j < $cnt; $j += 4) {
223 250 if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
224 251 $cOffset = $c + $convmap[$j + 2] & $convmap[$j + 3];
225 - $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#' . $cOffset . ';';
252 + $result .= $is_hex ? \sprintf('&#x%X;', $cOffset) : '&#' . $cOffset . ';';
226 253 continue 2;
227 254 }
228 255 }
229 256 $result .= $uchr;
@@ -230,9 +257,9 @@
230 257 }
231 258 if (null === $encoding) {
232 259 return $result;
233 260 }
234 - return iconv('UTF-8', $encoding . '//IGNORE', $result);
261 + return self::iconv('UTF-8', $encoding, $result);
235 262 }
236 263 public static function mb_convert_case($s, $mode, $encoding = null)
237 264 {
238 265 $s = (string) $s;
@@ -242,12 +269,12 @@
242 269 $encoding = self::getEncoding($encoding);
243 270 if ('UTF-8' === $encoding) {
244 271 $encoding = null;
245 272 if (!preg_match('//u', $s)) {
246 - $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
273 + $s = @self::iconv('UTF-8', 'UTF-8', $s);
247 274 }
248 275 } else {
249 - $s = iconv($encoding, 'UTF-8//IGNORE', $s);
276 + $s = self::iconv($encoding, 'UTF-8', $s);
250 277 }
251 278 if (\MB_CASE_TITLE == $mode) {
252 279 static $titleRegexp = null;
253 280 if (null === $titleRegexp) {
@@ -300,9 +327,9 @@
300 327 }
301 328 if (null === $encoding) {
302 329 return $s;
303 330 }
304 - return iconv('UTF-8', $encoding . '//IGNORE', $s);
331 + return self::iconv('UTF-8', $encoding, $s);
305 332 }
306 333 public static function mb_internal_encoding($encoding = null)
307 334 {
308 335 if (null === $encoding) {
@@ -315,9 +342,9 @@
315 342 }
316 343 if (80000 > \PHP_VERSION_ID) {
317 344 return \false;
318 345 }
319 - throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
346 + throw new \ValueError(\sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
320 347 }
321 348 public static function mb_language($lang = null)
322 349 {
323 350 if (null === $lang) {
@@ -331,9 +358,9 @@
331 358 }
332 359 if (80000 > \PHP_VERSION_ID) {
333 360 return \false;
334 361 }
335 - throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
362 + throw new \ValueError(\sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
336 363 }
337 364 public static function mb_list_encodings()
338 365 {
339 366 return ['UTF-8'];
@@ -428,9 +455,15 @@
428 455 $encoding = self::getEncoding($encoding);
429 456 if ('CP850' === $encoding || 'ASCII' === $encoding) {
430 457 return \strlen($s);
431 458 }
432 - return @iconv_strlen($s, $encoding);
459 + if (\false !== $len = @iconv_strlen($s, $encoding)) {
460 + return $len;
461 + }
462 + if ('UTF-8' !== $encoding) {
463 + return $len;
464 + }
465 + return preg_match_all('/[\x00-\x7F]|[\xC0-\xDF][\x80-\xBF]?|[\xE0-\xEF][\x80-\xBF]{0,2}|[\xF0-\xF7][\x80-\xBF]{0,3}|[\xF8-\xFB][\x80-\xBF]{0,4}|[\xFC-\xFD][\x80-\xBF]{0,5}|[\x80-\xBF\xFE\xFF]/s', $s);
433 466 }
434 467 public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
435 468 {
436 469 $encoding = self::getEncoding($encoding);
@@ -614,9 +647,9 @@
614 647 public static function mb_strwidth($s, $encoding = null)
615 648 {
616 649 $encoding = self::getEncoding($encoding);
617 650 if ('UTF-8' !== $encoding) {
618 - $s = iconv($encoding, 'UTF-8//IGNORE', $s);
651 + $s = self::iconv($encoding, 'UTF-8', $s);
619 652 }
620 653 $s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
621 654 return ($wide << 1) + iconv_strlen($s, 'UTF-8');
622 655 }
@@ -663,21 +696,40 @@
663 696 return ($code - 0xc0 << 6) + $s[2] - 0x80;
664 697 }
665 698 return $code;
666 699 }
667 - public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null): string
700 + /** @return string|false */
701 + public static function mb_scrub(?string $string, ?string $encoding = null): string
668 702 {
669 - if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], \true)) {
670 - throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
703 + if (null === $encoding) {
704 + $encoding = self::mb_internal_encoding();
705 + } elseif (!self::assertEncoding($encoding, 'mb_scrub(): Argument #2 ($encoding) must be a valid encoding, "%s" given')) {
706 + return \false;
671 707 }
708 + return self::mb_convert_encoding((string) $string, $encoding, $encoding);
709 + }
710 + /** @return string|false */
711 + public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null)
712 + {
672 713 if (null === $encoding) {
673 714 $encoding = self::mb_internal_encoding();
674 - } else {
675 - self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given');
715 + } elseif (!self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given')) {
716 + return \false;
676 717 }
677 718 if (self::mb_strlen($pad_string, $encoding) <= 0) {
719 + if (\PHP_VERSION_ID < 80000) {
720 + trigger_error('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string', \E_USER_WARNING);
721 + return \false;
722 + }
678 723 throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
679 724 }
725 + if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], \true)) {
726 + if (\PHP_VERSION_ID < 80000) {
727 + trigger_error('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH', \E_USER_WARNING);
728 + return \false;
729 + }
730 + throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
731 + }
680 732 $paddingRequired = $length - self::mb_strlen($string, $encoding);
681 733 if ($paddingRequired < 1) {
682 734 return $string;
683 735 }
@@ -691,30 +743,47 @@
691 743 $rightPaddingLength = $paddingRequired - $leftPaddingLength;
692 744 return self::mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding) . $string . self::mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
693 745 }
694 746 }
695 - public static function mb_ucfirst(string $string, ?string $encoding = null): string
747 + /** @return string|false */
748 + public static function mb_ucfirst(string $string, ?string $encoding = null)
696 749 {
697 750 if (null === $encoding) {
698 751 $encoding = self::mb_internal_encoding();
699 - } else {
700 - self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
752 + } elseif (!self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given')) {
753 + return \false;
701 754 }
702 755 $firstChar = mb_substr($string, 0, 1, $encoding);
703 756 $firstChar = mb_convert_case($firstChar, \MB_CASE_TITLE, $encoding);
704 757 return $firstChar . mb_substr($string, 1, null, $encoding);
705 758 }
706 - public static function mb_lcfirst(string $string, ?string $encoding = null): string
759 + /** @return string|false */
760 + public static function mb_lcfirst(string $string, ?string $encoding = null)
707 761 {
708 762 if (null === $encoding) {
709 763 $encoding = self::mb_internal_encoding();
710 - } else {
711 - self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
764 + } elseif (!self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given')) {
765 + return \false;
712 766 }
713 767 $firstChar = mb_substr($string, 0, 1, $encoding);
714 768 $firstChar = mb_convert_case($firstChar, \MB_CASE_LOWER, $encoding);
715 769 return $firstChar . mb_substr($string, 1, null, $encoding);
716 770 }
771 + /** @return string|false */
772 + public static function mb_trim(string $string, ?string $characters = null, ?string $encoding = null)
773 + {
774 + return self::mb_internal_trim('{^[%s]+|[%1$s]+$}Du', $string, $characters, $encoding, __FUNCTION__);
775 + }
776 + /** @return string|false */
777 + public static function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null)
778 + {
779 + return self::mb_internal_trim('{^[%s]+}Du', $string, $characters, $encoding, __FUNCTION__);
780 + }
781 + /** @return string|false */
782 + public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null)
783 + {
784 + return self::mb_internal_trim('{[%s]+$}Du', $string, $characters, $encoding, __FUNCTION__);
785 + }
717 786 private static function getSubpart($pos, $part, $haystack, $encoding)
718 787 {
719 788 if (\false === $pos) {
720 789 return \false;
@@ -770,28 +839,30 @@
770 839 }
771 840 if ('UTF8' === $encoding) {
772 841 return 'UTF-8';
773 842 }
843 + if ('UTF-32' === $encoding) {
844 + return 'UTF-32BE';
845 + }
846 + if ('UTF-16' === $encoding) {
847 + return 'UTF-16BE';
848 + }
774 849 return $encoding;
775 850 }
776 - public static function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string
851 + private static function iconv($fromEncoding, $toEncoding, $s)
777 852 {
778 - return self::mb_internal_trim('{^[%s]+|[%1$s]+$}Du', $string, $characters, $encoding, __FUNCTION__);
853 + if (null === self::$iconvSupportsIgnore) {
854 + self::$iconvSupportsIgnore = \false !== @iconv('UTF-8', 'UTF-8//IGNORE', '');
855 + }
856 + return self::$iconvSupportsIgnore ? iconv($fromEncoding, $toEncoding . '//IGNORE', $s) : iconv($fromEncoding, $toEncoding, $s);
779 857 }
780 - public static function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string
858 + /** @return string|false */
859 + private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function)
781 860 {
782 - return self::mb_internal_trim('{^[%s]+}Du', $string, $characters, $encoding, __FUNCTION__);
783 - }
784 - public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string
785 - {
786 - return self::mb_internal_trim('{[%s]+$}Du', $string, $characters, $encoding, __FUNCTION__);
787 - }
788 - private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function): string
789 - {
790 861 if (null === $encoding) {
791 862 $encoding = self::mb_internal_encoding();
792 - } else {
793 - self::assertEncoding($encoding, $function . '(): Argument #3 ($encoding) must be a valid encoding, "%s" given');
863 + } elseif (!self::assertEncoding($encoding, $function . '(): Argument #3 ($encoding) must be a valid encoding, "%s" given')) {
864 + return \false;
794 865 }
795 866 if ('' === $characters) {
796 867 return null === $encoding ? $string : self::mb_convert_encoding($string, $encoding);
797 868 }
@@ -797,17 +868,17 @@
797 868 }
798 869 if ('UTF-8' === $encoding) {
799 870 $encoding = null;
800 871 if (!preg_match('//u', $string)) {
801 - $string = @iconv('UTF-8', 'UTF-8//IGNORE', $string);
872 + $string = @self::iconv('UTF-8', 'UTF-8', $string);
802 873 }
803 874 if (null !== $characters && !preg_match('//u', $characters)) {
804 - $characters = @iconv('UTF-8', 'UTF-8//IGNORE', $characters);
875 + $characters = @self::iconv('UTF-8', 'UTF-8', $characters);
805 876 }
806 877 } else {
807 - $string = iconv($encoding, 'UTF-8//IGNORE', $string);
878 + $string = self::iconv($encoding, 'UTF-8', $string);
808 879 if (null !== $characters) {
809 - $characters = iconv($encoding, 'UTF-8//IGNORE', $characters);
880 + $characters = self::iconv($encoding, 'UTF-8', $characters);
810 881 }
811 882 }
812 883 if (null === $characters) {
813 884 $characters = "\\0 \f\n\r\t\v             

   …᠎";
@@ -813,23 +884,27 @@
813 884 $characters = "\\0 \f\n\r\t\v             

   …᠎";
814 885 } else {
815 886 $characters = preg_quote($characters);
816 887 }
817 - $string = preg_replace(sprintf($regex, $characters), '', $string);
888 + $string = preg_replace(\sprintf($regex, $characters), '', $string);
818 889 if (null === $encoding) {
819 890 return $string;
820 891 }
821 - return iconv('UTF-8', $encoding . '//IGNORE', $string);
892 + return self::iconv('UTF-8', $encoding, $string);
822 893 }
823 - private static function assertEncoding(string $encoding, string $errorFormat): void
894 + private static function assertEncoding(string $encoding, string $errorFormat): bool
824 895 {
825 896 try {
826 897 $validEncoding = @self::mb_check_encoding('', $encoding);
827 898 } catch (\ValueError $e) {
828 - throw new \ValueError(sprintf($errorFormat, $encoding));
899 + throw new \ValueError(\sprintf($errorFormat, $encoding));
829 900 }
830 - // BC for PHP 7.3 and lower
831 901 if (!$validEncoding) {
832 - throw new \ValueError(sprintf($errorFormat, $encoding));
902 + if (80000 > \PHP_VERSION_ID) {
903 + trigger_error(\sprintf($errorFormat, $encoding), \E_USER_WARNING);
904 + } else {
905 + throw new \ValueError(\sprintf($errorFormat, $encoding));
906 + }
833 907 }
908 + return $validEncoding;
834 909 }
835 910 }