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 +122 -7 5.566.76 View file →
@@ -1,9 +1,10 @@
1 1 <?php
2 +// phpcs:disable WordPress.Security.EscapeOutput.ExceptionNotEscaped
2 3 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3 4
4 -if (!trait_exists('WPRProtectFWRuleStringFunc_V556')) :
5 -trait WPRProtectFWRuleStringFunc_V556 {
5 +if (!trait_exists('WPRProtectFWRuleStringFunc_V676')) :
6 +trait WPRProtectFWRuleStringFunc_V676 {
6 7 private function _rf_isNumeric() {
7 8 $args = $this->processRuleFunctionParams(
8 9 'isNumeric',
9 10 func_num_args(),
@@ -236,9 +237,9 @@
236 237 return true;
237 238 }
238 239 }
239 240 } else {
240 - throw new WPRProtectRuleError_V556(
241 + throw new WPRProtectRuleError_V676(
241 242 $this->addExState("containsAnySubstring: Expects an array of substrings.")
242 243 );
243 244 }
244 245
@@ -271,9 +272,9 @@
271 272 $needle = $args[1];
272 273 $offset = isset($args[2]) ? $args[2] : 0;
273 274
274 275 if (!is_int($offset)) {
275 - throw new WPRProtectRuleError_V556(
276 + throw new WPRProtectRuleError_V676(
276 277 $this->addExState("strPos: Offset should be an integer")
277 278 );
278 279 }
279 280
@@ -316,15 +317,15 @@
316 317 $str = $args[1];
317 318 $limit = isset($args[2]) ? $args[2] : PHP_INT_MAX;
318 319
319 320 if (empty($separator)) {
320 - throw new WPRProtectRuleError_V556(
321 + throw new WPRProtectRuleError_V676(
321 322 $this->addExState("splitString: Separator cannot be empty")
322 323 );
323 324 }
324 325
325 326 if (!is_int($limit)) {
326 - throw new WPRProtectRuleError_V556(
327 + throw new WPRProtectRuleError_V676(
327 328 $this->addExState("splitString: Limit should be an integer")
328 329 );
329 330 }
330 331
@@ -329,6 +330,120 @@
329 330 }
330 331
331 332 return explode($separator, $str, $limit);
332 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 + }
333 448 }
334 -endif;
449 +endif;