PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev2
Elementor Website Builder – more than just a page builder v3.35.0-dev2
4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 All 454 releases
← All changes | vendor_prefixed/twig/symfony/polyfill-mbstring/Mbstring.php +48 -123 4.3.0 → 3.35.0-dev2 View file →
@@ -75,9 +75,8 @@
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;
80 79 public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
81 80 {
82 81 if (\is_array($s)) {
83 82 $r = [];
@@ -103,48 +102,22 @@
103 102 if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
104 103 $fromEncoding = 'Windows-1252';
105 104 }
106 105 if ('UTF-8' !== $fromEncoding) {
107 - $s = self::iconv($fromEncoding, 'UTF-8', $s);
106 + $s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
108 107 }
109 108 return \preg_replace_callback('/[\\x80-\\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
110 109 }
111 110 if ('HTML-ENTITIES' === $fromEncoding) {
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 - }
111 + $s = \html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
139 112 $fromEncoding = 'UTF-8';
140 113 }
141 - return self::iconv($fromEncoding, $toEncoding, $s);
114 + return \iconv($fromEncoding, $toEncoding . '//IGNORE', $s);
142 115 }
143 116 public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
144 117 {
145 118 $ok = \true;
146 - \array_walk_recursive($vars, static function (&$v) use(&$ok, $toEncoding, $fromEncoding) {
119 + \array_walk_recursive($vars, function (&$v) use(&$ok, $toEncoding, $fromEncoding) {
147 120 if (\false === ($v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding))) {
148 121 $ok = \false;
149 122 }
150 123 });
@@ -179,12 +152,12 @@
179 152 $encoding = self::getEncoding($encoding);
180 153 if ('UTF-8' === $encoding) {
181 154 $encoding = null;
182 155 if (!\preg_match('//u', $s)) {
183 - $s = @self::iconv('UTF-8', 'UTF-8', $s);
156 + $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
184 157 }
185 158 } else {
186 - $s = self::iconv($encoding, 'UTF-8', $s);
159 + $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
187 160 }
188 161 $cnt = \floor(\count($convmap) / 4) * 4;
189 162 for ($i = 0; $i < $cnt; $i += 4) {
190 163 // collector_decode_htmlnumericentity ignores $convmap[$i + 3]
@@ -190,9 +163,9 @@
190 163 // collector_decode_htmlnumericentity ignores $convmap[$i + 3]
191 164 $convmap[$i] += $convmap[$i + 2];
192 165 $convmap[$i + 1] += $convmap[$i + 2];
193 166 }
194 - $s = \preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))' . (\PHP_VERSION_ID >= 80200 ? '' : '(?!&)') . ';?/', static function (array $m) use($cnt, $convmap) {
167 + $s = \preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use($cnt, $convmap) {
195 168 $c = isset($m[2]) ? (int) \hexdec($m[2]) : $m[1];
196 169 for ($i = 0; $i < $cnt; $i += 4) {
197 170 if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
198 171 return self::mb_chr($c - $convmap[$i + 2]);
@@ -202,9 +175,9 @@
202 175 }, $s);
203 176 if (null === $encoding) {
204 177 return $s;
205 178 }
206 - return self::iconv('UTF-8', $encoding, $s);
179 + return \iconv('UTF-8', $encoding . '//IGNORE', $s);
207 180 }
208 181 public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = \false)
209 182 {
210 183 if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
@@ -230,12 +203,12 @@
230 203 $encoding = self::getEncoding($encoding);
231 204 if ('UTF-8' === $encoding) {
232 205 $encoding = null;
233 206 if (!\preg_match('//u', $s)) {
234 - $s = @self::iconv('UTF-8', 'UTF-8', $s);
207 + $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
235 208 }
236 209 } else {
237 - $s = self::iconv($encoding, 'UTF-8', $s);
210 + $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
238 211 }
239 212 static $ulenMask = ["\xc0" => 2, "\xd0" => 2, "\xe0" => 3, "\xf0" => 4];
240 213 $cnt = \floor(\count($convmap) / 4) * 4;
241 214 $i = 0;
@@ -257,9 +230,9 @@
257 230 }
258 231 if (null === $encoding) {
259 232 return $result;
260 233 }
261 - return self::iconv('UTF-8', $encoding, $result);
234 + return \iconv('UTF-8', $encoding . '//IGNORE', $result);
262 235 }
263 236 public static function mb_convert_case($s, $mode, $encoding = null)
264 237 {
265 238 $s = (string) $s;
@@ -269,12 +242,12 @@
269 242 $encoding = self::getEncoding($encoding);
270 243 if ('UTF-8' === $encoding) {
271 244 $encoding = null;
272 245 if (!\preg_match('//u', $s)) {
273 - $s = @self::iconv('UTF-8', 'UTF-8', $s);
246 + $s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
274 247 }
275 248 } else {
276 - $s = self::iconv($encoding, 'UTF-8', $s);
249 + $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
277 250 }
278 251 if (\MB_CASE_TITLE == $mode) {
279 252 static $titleRegexp = null;
280 253 if (null === $titleRegexp) {
@@ -327,9 +300,9 @@
327 300 }
328 301 if (null === $encoding) {
329 302 return $s;
330 303 }
331 - return self::iconv('UTF-8', $encoding, $s);
304 + return \iconv('UTF-8', $encoding . '//IGNORE', $s);
332 305 }
333 306 public static function mb_internal_encoding($encoding = null)
334 307 {
335 308 if (null === $encoding) {
@@ -455,15 +428,9 @@
455 428 $encoding = self::getEncoding($encoding);
456 429 if ('CP850' === $encoding || 'ASCII' === $encoding) {
457 430 return \strlen($s);
458 431 }
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);
432 + return @\iconv_strlen($s, $encoding);
466 433 }
467 434 public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
468 435 {
469 436 $encoding = self::getEncoding($encoding);
@@ -647,9 +614,9 @@
647 614 public static function mb_strwidth($s, $encoding = null)
648 615 {
649 616 $encoding = self::getEncoding($encoding);
650 617 if ('UTF-8' !== $encoding) {
651 - $s = self::iconv($encoding, 'UTF-8', $s);
618 + $s = \iconv($encoding, 'UTF-8//IGNORE', $s);
652 619 }
653 620 $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);
654 621 return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
655 622 }
@@ -696,40 +663,21 @@
696 663 return ($code - 0xc0 << 6) + $s[2] - 0x80;
697 664 }
698 665 return $code;
699 666 }
700 - /** @return string|false */
701 - public static function mb_scrub(?string $string, ?string $encoding = null) : string
667 + public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null) : string
702 668 {
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;
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');
707 671 }
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 - {
713 672 if (null === $encoding) {
714 673 $encoding = self::mb_internal_encoding();
715 - } elseif (!self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given')) {
716 - return \false;
674 + } else {
675 + self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given');
717 676 }
718 677 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 - }
723 678 throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
724 679 }
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 - }
732 680 $paddingRequired = $length - self::mb_strlen($string, $encoding);
733 681 if ($paddingRequired < 1) {
734 682 return $string;
735 683 }
@@ -743,47 +691,30 @@
743 691 $rightPaddingLength = $paddingRequired - $leftPaddingLength;
744 692 return self::mb_substr(\str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding) . $string . self::mb_substr(\str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
745 693 }
746 694 }
747 - /** @return string|false */
748 - public static function mb_ucfirst(string $string, ?string $encoding = null)
695 + public static function mb_ucfirst(string $string, ?string $encoding = null) : string
749 696 {
750 697 if (null === $encoding) {
751 698 $encoding = self::mb_internal_encoding();
752 - } elseif (!self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given')) {
753 - return \false;
699 + } else {
700 + self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
754 701 }
755 702 $firstChar = \mb_substr($string, 0, 1, $encoding);
756 703 $firstChar = \mb_convert_case($firstChar, \MB_CASE_TITLE, $encoding);
757 704 return $firstChar . \mb_substr($string, 1, null, $encoding);
758 705 }
759 - /** @return string|false */
760 - public static function mb_lcfirst(string $string, ?string $encoding = null)
706 + public static function mb_lcfirst(string $string, ?string $encoding = null) : string
761 707 {
762 708 if (null === $encoding) {
763 709 $encoding = self::mb_internal_encoding();
764 - } elseif (!self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given')) {
765 - return \false;
710 + } else {
711 + self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
766 712 }
767 713 $firstChar = \mb_substr($string, 0, 1, $encoding);
768 714 $firstChar = \mb_convert_case($firstChar, \MB_CASE_LOWER, $encoding);
769 715 return $firstChar . \mb_substr($string, 1, null, $encoding);
770 716 }
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 - }
786 717 private static function getSubpart($pos, $part, $haystack, $encoding)
787 718 {
788 719 if (\false === $pos) {
789 720 return \false;
@@ -839,30 +770,28 @@
839 770 }
840 771 if ('UTF8' === $encoding) {
841 772 return 'UTF-8';
842 773 }
843 - if ('UTF-32' === $encoding) {
844 - return 'UTF-32BE';
845 - }
846 - if ('UTF-16' === $encoding) {
847 - return 'UTF-16BE';
848 - }
849 774 return $encoding;
850 775 }
851 - private static function iconv($fromEncoding, $toEncoding, $s)
776 + public static function mb_trim(string $string, ?string $characters = null, ?string $encoding = null) : string
852 777 {
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);
778 + return self::mb_internal_trim('{^[%s]+|[%1$s]+$}Du', $string, $characters, $encoding, __FUNCTION__);
857 779 }
858 - /** @return string|false */
859 - private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function)
780 + public static function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null) : string
860 781 {
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 + {
861 790 if (null === $encoding) {
862 791 $encoding = self::mb_internal_encoding();
863 - } elseif (!self::assertEncoding($encoding, $function . '(): Argument #3 ($encoding) must be a valid encoding, "%s" given')) {
864 - return \false;
792 + } else {
793 + self::assertEncoding($encoding, $function . '(): Argument #3 ($encoding) must be a valid encoding, "%s" given');
865 794 }
866 795 if ('' === $characters) {
867 796 return null === $encoding ? $string : self::mb_convert_encoding($string, $encoding);
868 797 }
@@ -868,17 +797,17 @@
868 797 }
869 798 if ('UTF-8' === $encoding) {
870 799 $encoding = null;
871 800 if (!\preg_match('//u', $string)) {
872 - $string = @self::iconv('UTF-8', 'UTF-8', $string);
801 + $string = @\iconv('UTF-8', 'UTF-8//IGNORE', $string);
873 802 }
874 803 if (null !== $characters && !\preg_match('//u', $characters)) {
875 - $characters = @self::iconv('UTF-8', 'UTF-8', $characters);
804 + $characters = @\iconv('UTF-8', 'UTF-8//IGNORE', $characters);
876 805 }
877 806 } else {
878 - $string = self::iconv($encoding, 'UTF-8', $string);
807 + $string = \iconv($encoding, 'UTF-8//IGNORE', $string);
879 808 if (null !== $characters) {
880 - $characters = self::iconv($encoding, 'UTF-8', $characters);
809 + $characters = \iconv($encoding, 'UTF-8//IGNORE', $characters);
881 810 }
882 811 }
883 812 if (null === $characters) {
884 813 $characters = "\\0 \f\n\r\t\v             

   …᠎";
@@ -888,11 +817,11 @@
888 817 $string = \preg_replace(\sprintf($regex, $characters), '', $string);
889 818 if (null === $encoding) {
890 819 return $string;
891 820 }
892 - return self::iconv('UTF-8', $encoding, $string);
821 + return \iconv('UTF-8', $encoding . '//IGNORE', $string);
893 822 }
894 - private static function assertEncoding(string $encoding, string $errorFormat) : bool
823 + private static function assertEncoding(string $encoding, string $errorFormat) : void
895 824 {
896 825 try {
897 826 $validEncoding = @self::mb_check_encoding('', $encoding);
898 827 } catch (\ValueError $e) {
@@ -897,14 +826,10 @@
897 826 $validEncoding = @self::mb_check_encoding('', $encoding);
898 827 } catch (\ValueError $e) {
899 828 throw new \ValueError(\sprintf($errorFormat, $encoding));
900 829 }
830 + // BC for PHP 7.3 and lower
901 831 if (!$validEncoding) {
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 - }
832 + throw new \ValueError(\sprintf($errorFormat, $encoding));
907 833 }
908 - return $validEncoding;
909 834 }
910 835 }