PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / lib / packages / Safe / generated / mbstring.php

mbstring.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at lib/packages/Safe/generated/mbstring.php

536 lines 15.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WP_DEFENDER_VENDOR\Safe;
4
5 use WP_DEFENDER_VENDOR\Safe\Exceptions\MbstringException;
6
7 /**
8 *
9 *
10 * @param int $cp
11 * @param string|null $encoding
12 *
13 * @return string Returns a specific character.
14 * @throws MbstringException
15 *
16 */
17 function mb_chr(int $cp, ?string $encoding = null): string
18 {
19 error_clear_last();
20 if ($encoding !== null) {
21 $result = \mb_chr($cp, $encoding);
22 } else {
23 $result = \mb_chr($cp);
24 }
25 if ($result === false) {
26 throw MbstringException::createFromPhpError();
27 }
28 return $result;
29 }
30
31
32 /**
33 * Sets the automatic character
34 * encoding detection order to encoding_list.
35 *
36 * @param mixed $encoding_list encoding_list is an array or
37 * comma separated list of character encoding. See supported encodings.
38 *
39 * If encoding_list is omitted, it returns
40 * the current character encoding detection order as array.
41 *
42 * This setting affects mb_detect_encoding and
43 * mb_send_mail.
44 *
45 * mbstring currently implements the following
46 * encoding detection filters. If there is an invalid byte sequence
47 * for the following encodings, encoding detection will fail.
48 *
49 * For ISO-8859-*, mbstring
50 * always detects as ISO-8859-*.
51 *
52 * For UTF-16, UTF-32,
53 * UCS2 and UCS4, encoding
54 * detection will fail always.
55 * @return bool|array When setting the encoding detection order, TRUE is returned on success.
56 *
57 * When getting the encoding detection order, an ordered array of the encodings is returned.
58 * @throws MbstringException
59 *
60 */
61 function mb_detect_order($encoding_list = null)
62 {
63 error_clear_last();
64 if ($encoding_list !== null) {
65 $result = \mb_detect_order($encoding_list);
66 } else {
67 $result = \mb_detect_order();
68 }
69 if ($result === false) {
70 throw MbstringException::createFromPhpError();
71 }
72 return $result;
73 }
74
75
76 /**
77 * Returns an array of aliases for a known encoding type.
78 *
79 * @param string $encoding The encoding type being checked, for aliases.
80 * @return array Returns a numerically indexed array of encoding aliases on success
81 * @throws MbstringException
82 *
83 */
84 function mb_encoding_aliases(string $encoding): array
85 {
86 error_clear_last();
87 $result = \mb_encoding_aliases($encoding);
88 if ($result === false) {
89 throw MbstringException::createFromPhpError();
90 }
91 return $result;
92 }
93
94
95 /**
96 * Scans string for matches to
97 * pattern, then replaces the matched text
98 * with the output of callback function.
99 *
100 * The behavior of this function is almost identical to mb_ereg_replace,
101 * except for the fact that instead of
102 * replacement parameter, one should specify a
103 * callback.
104 *
105 * @param string $pattern The regular expression pattern.
106 *
107 * Multibyte characters may be used in pattern.
108 * @param callable $callback A callback that will be called and passed an array of matched elements
109 * in the subject string. The callback should
110 * return the replacement string.
111 *
112 * You'll often need the callback function
113 * for a mb_ereg_replace_callback in just one place.
114 * In this case you can use an
115 * anonymous function to
116 * declare the callback within the call to
117 * mb_ereg_replace_callback. By doing it this way
118 * you have all information for the call in one place and do not
119 * clutter the function namespace with a callback function's name
120 * not used anywhere else.
121 * @param string $string The string being checked.
122 * @param string $option The search option. See mb_regex_set_options for explanation.
123 * @return string The resultant string on success.
124 * @throws MbstringException
125 *
126 */
127 function mb_ereg_replace_callback(string $pattern, callable $callback, string $string, string $option = "msr"): string
128 {
129 error_clear_last();
130 $result = \mb_ereg_replace_callback($pattern, $callback, $string, $option);
131 if ($result === false) {
132 throw MbstringException::createFromPhpError();
133 }
134 return $result;
135 }
136
137
138 /**
139 *
140 *
141 * @param string $pattern The regular expression pattern.
142 *
143 * Multibyte characters may be used in pattern.
144 * @param string $replacement The replacement text.
145 * @param string $string The string being checked.
146 * @param string $option
147 * @return string The resultant string on success.
148 * @throws MbstringException
149 *
150 */
151 function mb_ereg_replace(string $pattern, string $replacement, string $string, string $option = "msr"): string
152 {
153 error_clear_last();
154 $result = \mb_ereg_replace($pattern, $replacement, $string, $option);
155 if ($result === false) {
156 throw MbstringException::createFromPhpError();
157 }
158 return $result;
159 }
160
161
162 /**
163 *
164 *
165 * @return array
166 * @throws MbstringException
167 *
168 */
169 function mb_ereg_search_getregs(): array
170 {
171 error_clear_last();
172 $result = \mb_ereg_search_getregs();
173 if ($result === false) {
174 throw MbstringException::createFromPhpError();
175 }
176 return $result;
177 }
178
179
180 /**
181 * mb_ereg_search_init sets
182 * string and pattern
183 * for a multibyte regular expression. These values are used for
184 * mb_ereg_search,
185 * mb_ereg_search_pos, and
186 * mb_ereg_search_regs.
187 *
188 * @param string $string The search string.
189 * @param string|null $pattern The search pattern.
190 * @param string $option The search option. See mb_regex_set_options for explanation.
191 *
192 * @throws MbstringException
193 *
194 */
195 function mb_ereg_search_init(string $string, ?string $pattern = null, string $option = "msr"): void
196 {
197 error_clear_last();
198 if ($option !== "msr") {
199 $result = \mb_ereg_search_init($string, $pattern, $option);
200 } elseif ($pattern !== null) {
201 $result = \mb_ereg_search_init($string, $pattern);
202 } else {
203 $result = \mb_ereg_search_init($string);
204 }
205 if ($result === false) {
206 throw MbstringException::createFromPhpError();
207 }
208 }
209
210
211 /**
212 * Returns the matched part of a multibyte regular expression.
213 *
214 * @param string|null $pattern The search pattern.
215 * @param string $option The search option. See mb_regex_set_options for explanation.
216 *
217 * @return array
218 * @throws MbstringException
219 *
220 */
221 function mb_ereg_search_regs(?string $pattern = null, string $option = "ms"): array
222 {
223 error_clear_last();
224 if ($option !== "ms") {
225 $result = \mb_ereg_search_regs($pattern, $option);
226 } elseif ($pattern !== null) {
227 $result = \mb_ereg_search_regs($pattern);
228 } else {
229 $result = \mb_ereg_search_regs();
230 }
231 if ($result === false) {
232 throw MbstringException::createFromPhpError();
233 }
234 return $result;
235 }
236
237
238 /**
239 *
240 *
241 * @param int $position The position to set. If it is negative, it counts from the end of the string.
242 * @throws MbstringException
243 *
244 */
245 function mb_ereg_search_setpos(int $position): void
246 {
247 error_clear_last();
248 $result = \mb_ereg_search_setpos($position);
249 if ($result === false) {
250 throw MbstringException::createFromPhpError();
251 }
252 }
253
254
255 /**
256 *
257 *
258 * @param string $pattern The regular expression pattern. Multibyte characters may be used. The case will be ignored.
259 * @param string $replace The replacement text.
260 * @param string $string The searched string.
261 * @param string $option
262 * @return string The resultant string.
263 * @throws MbstringException
264 *
265 */
266 function mb_eregi_replace(string $pattern, string $replace, string $string, string $option = "msri"): string
267 {
268 error_clear_last();
269 $result = \mb_eregi_replace($pattern, $replace, $string, $option);
270 if ($result === false) {
271 throw MbstringException::createFromPhpError();
272 }
273 return $result;
274 }
275
276
277 /**
278 * Set/Get the HTTP output character encoding.
279 * Output after this function is called will be converted from the set internal encoding to encoding.
280 *
281 * @param string|null $encoding If encoding is set,
282 * mb_http_output sets the HTTP output character
283 * encoding to encoding.
284 *
285 * If encoding is omitted,
286 * mb_http_output returns the current HTTP output
287 * character encoding.
288 *
289 * @return string|bool If encoding is omitted,
290 * mb_http_output returns the current HTTP output
291 * character encoding. Otherwise,
292 * Returns TRUE on success.
293 * @throws MbstringException
294 *
295 */
296 function mb_http_output(?string $encoding = null)
297 {
298 error_clear_last();
299 if ($encoding !== null) {
300 $result = \mb_http_output($encoding);
301 } else {
302 $result = \mb_http_output();
303 }
304 if ($result === false) {
305 throw MbstringException::createFromPhpError();
306 }
307 return $result;
308 }
309
310
311 /**
312 * Set/Get the internal character encoding
313 *
314 * @param string|null $encoding encoding is the character encoding name
315 * used for the HTTP input character encoding conversion, HTTP output
316 * character encoding conversion, and the default character encoding
317 * for string functions defined by the mbstring module.
318 * You should notice that the internal encoding is totally different from the one for multibyte regex.
319 *
320 * @return string|bool If encoding is set, then
321 * Returns TRUE on success.
322 * In this case, the character encoding for multibyte regex is NOT changed.
323 * If encoding is omitted, then
324 * the current character encoding name is returned.
325 * @throws MbstringException
326 *
327 */
328 function mb_internal_encoding(?string $encoding = null)
329 {
330 error_clear_last();
331 if ($encoding !== null) {
332 $result = \mb_internal_encoding($encoding);
333 } else {
334 $result = \mb_internal_encoding();
335 }
336 if ($result === false) {
337 throw MbstringException::createFromPhpError();
338 }
339 return $result;
340 }
341
342
343 /**
344 *
345 *
346 * @param string $str
347 * @param string|null $encoding
348 *
349 * @return int Returns a code point of character.
350 * @throws MbstringException
351 *
352 */
353 function mb_ord(string $str, ?string $encoding = null): int
354 {
355 error_clear_last();
356 if ($encoding !== null) {
357 $result = \mb_ord($str, $encoding);
358 } else {
359 $result = \mb_ord($str);
360 }
361 if ($result === false) {
362 throw MbstringException::createFromPhpError();
363 }
364 return $result;
365 }
366
367
368 /**
369 * Parses GET/POST/COOKIE data and
370 * sets global variables. Since PHP does not provide raw POST/COOKIE
371 * data, it can only be used for GET data for now. It parses URL
372 * encoded data, detects encoding, converts coding to internal
373 * encoding and set values to the result array or
374 * global variables.
375 *
376 * @param string $encoded_string The URL encoded data.
377 * @param array|null $result An array containing decoded and character encoded converted values.
378 * @throws MbstringException
379 *
380 */
381 function mb_parse_str(string $encoded_string, ?array &$result): void
382 {
383 error_clear_last();
384 $result = \mb_parse_str($encoded_string, $result);
385 if ($result === false) {
386 throw MbstringException::createFromPhpError();
387 }
388 }
389
390
391 /**
392 * Set/Get character encoding for a multibyte regex.
393 *
394 * @param string|null $encoding The encoding
395 * parameter is the character encoding. If it is omitted, the internal character
396 * encoding value will be used.
397 *
398 * @return string|bool
399 * @throws MbstringException
400 *
401 */
402 function mb_regex_encoding(?string $encoding = null)
403 {
404 error_clear_last();
405 if ($encoding !== null) {
406 $result = \mb_regex_encoding($encoding);
407 } else {
408 $result = \mb_regex_encoding();
409 }
410 if ($result === false) {
411 throw MbstringException::createFromPhpError();
412 }
413 return $result;
414 }
415
416
417 /**
418 * Sends email. Headers and messages are converted and encoded according
419 * to the mb_language setting. It's a wrapper function
420 * for mail, so see also mail for details.
421 *
422 * @param string $to The mail addresses being sent to. Multiple
423 * recipients may be specified by putting a comma between each
424 * address in to.
425 * This parameter is not automatically encoded.
426 * @param string $subject The subject of the mail.
427 * @param string $message The message of the mail.
428 * @param string|array|null $additional_headers String or array to be inserted at the end of the email header.
429 *
430 * This is typically used to add extra headers (From, Cc, and Bcc).
431 * Multiple extra headers should be separated with a CRLF (\r\n).
432 * Validate parameter not to be injected unwanted headers by attackers.
433 *
434 * If an array is passed, its keys are the header names and its
435 * values are the respective header values.
436 *
437 * When sending mail, the mail must contain
438 * a From header. This can be set with the
439 * additional_headers parameter, or a default
440 * can be set in php.ini.
441 *
442 * Failing to do this will result in an error
443 * message similar to Warning: mail(): "sendmail_from" not
444 * set in php.ini or custom "From:" header missing.
445 * The From header sets also
446 * Return-Path under Windows.
447 *
448 * If messages are not received, try using a LF (\n) only.
449 * Some Unix mail transfer agents (most notably
450 * qmail) replace LF by CRLF
451 * automatically (which leads to doubling CR if CRLF is used).
452 * This should be a last resort, as it does not comply with
453 * RFC 2822.
454 * @param string|null $additional_parameter additional_parameter is a MTA command line
455 * parameter. It is useful when setting the correct Return-Path
456 * header when using sendmail.
457 *
458 * This parameter is escaped by escapeshellcmd internally
459 * to prevent command execution. escapeshellcmd prevents
460 * command execution, but allows to add additional parameters. For security reason,
461 * this parameter should be validated.
462 *
463 * Since escapeshellcmd is applied automatically, some characters
464 * that are allowed as email addresses by internet RFCs cannot be used. Programs
465 * that are required to use these characters mail cannot be used.
466 *
467 * The user that the webserver runs as should be added as a trusted user to the
468 * sendmail configuration to prevent a 'X-Warning' header from being added
469 * to the message when the envelope sender (-f) is set using this method.
470 * For sendmail users, this file is /etc/mail/trusted-users.
471 *
472 * @throws MbstringException
473 *
474 */
475 function mb_send_mail(string $to, string $subject, string $message, $additional_headers = null, ?string $additional_parameter = null): void
476 {
477 error_clear_last();
478 $result = \mb_send_mail($to, $subject, $message, $additional_headers, $additional_parameter);
479 if ($result === false) {
480 throw MbstringException::createFromPhpError();
481 }
482 }
483
484
485 /**
486 *
487 *
488 * @param string $pattern The regular expression pattern.
489 * @param string $string The string being split.
490 * @param int $limit
491 * @return array The result as an array.
492 * @throws MbstringException
493 *
494 */
495 function mb_split(string $pattern, string $string, int $limit = -1): array
496 {
497 error_clear_last();
498 $result = \mb_split($pattern, $string, $limit);
499 if ($result === false) {
500 throw MbstringException::createFromPhpError();
501 }
502 return $result;
503 }
504
505
506 /**
507 * This function will return an array of strings, it is a version of str_split with support for encodings of variable character size as well as fixed-size encodings of 1,2 or 4 byte characters.
508 * If the split_length parameter is specified, the string is broken down into chunks of the specified length in characters (not bytes).
509 * The encoding parameter can be optionally specified and it is good practice to do so.
510 *
511 * @param string $string The string to split into characters or chunks.
512 * @param int $split_length If specified, each element of the returned array will be composed of multiple characters instead of a single character.
513 * @param string|null $encoding The encoding
514 * parameter is the character encoding. If it is omitted, the internal character
515 * encoding value will be used.
516 *
517 * A string specifying one of the supported encodings.
518 *
519 * @return array mb_str_split returns an array of strings.
520 * @throws MbstringException
521 *
522 */
523 function mb_str_split(string $string, int $split_length = 1, ?string $encoding = null): array
524 {
525 error_clear_last();
526 if ($encoding !== null) {
527 $result = \mb_str_split($string, $split_length, $encoding);
528 } else {
529 $result = \mb_str_split($string, $split_length);
530 }
531 if ($result === false) {
532 throw MbstringException::createFromPhpError();
533 }
534 return $result;
535 }
536