PluginProbe
The WP Remote WordPress Plugin / 6.76
The WP Remote WordPress Plugin v6.76
6.76 6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 All 54 releases
← All changes | protect/fw/rule/functions/string.php +121 -7 6.476.76 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2 // phpcs:disable WordPress.Security.EscapeOutput.ExceptionNotEscaped
3 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
4 4
5 -if (!trait_exists('WPRProtectFWRuleStringFunc_V647')) :
6 -trait WPRProtectFWRuleStringFunc_V647 {
5 +if (!trait_exists('WPRProtectFWRuleStringFunc_V676')) :
6 +trait WPRProtectFWRuleStringFunc_V676 {
7 7 private function _rf_isNumeric() {
8 8 $args = $this->processRuleFunctionParams(
9 9 'isNumeric',
10 10 func_num_args(),
@@ -237,9 +237,9 @@
237 237 return true;
238 238 }
239 239 }
240 240 } else {
241 - throw new WPRProtectRuleError_V647(
241 + throw new WPRProtectRuleError_V676(
242 242 $this->addExState("containsAnySubstring: Expects an array of substrings.")
243 243 );
244 244 }
245 245
@@ -272,9 +272,9 @@
272 272 $needle = $args[1];
273 273 $offset = isset($args[2]) ? $args[2] : 0;
274 274
275 275 if (!is_int($offset)) {
276 - throw new WPRProtectRuleError_V647(
276 + throw new WPRProtectRuleError_V676(
277 277 $this->addExState("strPos: Offset should be an integer")
278 278 );
279 279 }
280 280
@@ -317,15 +317,15 @@
317 317 $str = $args[1];
318 318 $limit = isset($args[2]) ? $args[2] : PHP_INT_MAX;
319 319
320 320 if (empty($separator)) {
321 - throw new WPRProtectRuleError_V647(
321 + throw new WPRProtectRuleError_V676(
322 322 $this->addExState("splitString: Separator cannot be empty")
323 323 );
324 324 }
325 325
326 326 if (!is_int($limit)) {
327 - throw new WPRProtectRuleError_V647(
327 + throw new WPRProtectRuleError_V676(
328 328 $this->addExState("splitString: Limit should be an integer")
329 329 );
330 330 }
331 331
@@ -330,6 +330,120 @@
330 330 }
331 331
332 332 return explode($separator, $str, $limit);
333 333 }
334 +
335 + private function _rf_urlDecode() {
336 + $args = $this->processRuleFunctionParams(
337 + 'urlDecode',
338 + func_num_args(),
339 + func_get_args(),
340 + 1
341 + );
342 + $value = $args[0];
343 + $recursive = isset($args[1]) ? $args[1] : true;
344 +
345 + if (!is_bool($recursive)) {
346 + throw new WPRProtectRuleError_V676(
347 + $this->addExState("urlDecode: Recursive flag should be a boolean")
348 + );
349 + }
350 +
351 + return $this->normalizeStringValue($value, 'urlDecode', $recursive);
352 + }
353 +
354 + private function _rf_rawUrlDecode() {
355 + $args = $this->processRuleFunctionParams(
356 + 'rawUrlDecode',
357 + func_num_args(),
358 + func_get_args(),
359 + 1
360 + );
361 + $value = $args[0];
362 + $recursive = isset($args[1]) ? $args[1] : true;
363 +
364 + if (!is_bool($recursive)) {
365 + throw new WPRProtectRuleError_V676(
366 + $this->addExState("rawUrlDecode: Recursive flag should be a boolean")
367 + );
368 + }
369 +
370 + return $this->normalizeStringValue($value, 'rawUrlDecode', $recursive);
371 + }
372 +
373 + private function _rf_htmlEntityDecode() {
374 + $args = $this->processRuleFunctionParams(
375 + 'htmlEntityDecode',
376 + func_num_args(),
377 + func_get_args(),
378 + 1
379 + );
380 + $value = $args[0];
381 + $recursive = isset($args[1]) ? $args[1] : true;
382 +
383 + if (!is_bool($recursive)) {
384 + throw new WPRProtectRuleError_V676(
385 + $this->addExState("htmlEntityDecode: Recursive flag should be a boolean")
386 + );
387 + }
388 +
389 + return $this->normalizeStringValue($value, 'htmlEntityDecode', $recursive);
390 + }
391 +
392 + private function _rf_stripSlashes() {
393 + $args = $this->processRuleFunctionParams(
394 + 'stripSlashes',
395 + func_num_args(),
396 + func_get_args(),
397 + 1
398 + );
399 + $value = $args[0];
400 + $recursive = isset($args[1]) ? $args[1] : true;
401 +
402 + if (!is_bool($recursive)) {
403 + throw new WPRProtectRuleError_V676(
404 + $this->addExState("stripSlashes: Recursive flag should be a boolean")
405 + );
406 + }
407 +
408 + return $this->normalizeStringValue($value, 'stripSlashes', $recursive);
409 + }
410 +
411 + private function normalizeStringValue($value, $operation, $recursive, $depth = 1) {
412 + if ($depth > WPRProtectFWRuleEngine_V676::MAX_DEPTH_TO_ALLOWED_TYPE_FUNC) {
413 + return null;
414 + }
415 +
416 + if (is_array($value)) {
417 + if (!$recursive) {
418 + return $value;
419 + }
420 +
421 + $normalized = array();
422 + foreach ($value as $key => $item) {
423 + $normalized[$key] = $this->normalizeStringValue($item, $operation, $recursive, $depth + 1);
424 + }
425 +
426 + return $normalized;
427 + }
428 +
429 + if (!is_string($value)) {
430 + return $value;
431 + }
432 +
433 + switch ($operation) {
434 + case 'urlDecode':
435 + return urldecode($value);
436 + case 'rawUrlDecode':
437 + return rawurldecode($value);
438 + case 'htmlEntityDecode':
439 + return html_entity_decode($value, ENT_QUOTES | ENT_HTML5, 'UTF-8');
440 + case 'stripSlashes':
441 + return stripslashes($value);
442 + }
443 +
444 + throw new WPRProtectRuleError_V676(
445 + $this->addExState("normalizeStringValue: Invalid normalization operation")
446 + );
447 + }
334 448 }
335 -endif;
449 +endif;