| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit; |
| 4 | 4 | |
| 5 | -if (!class_exists('WPRProtectRequest_V662')) : | |
| 6 | -class WPRProtectRequest_V662 { | |
| 5 | +if (!class_exists('WPRProtectRequest_V676')) : | |
| 6 | +class WPRProtectRequest_V676 { | |
| 7 | 7 | public $ip; |
| 8 | 8 | public $host = ''; |
| 9 | 9 | public $uri; |
| 10 | 10 | public $method = ''; |
| @@ -18,10 +18,10 @@ | ||
| 18 | 18 | public $json_params = array(); |
| 19 | 19 | public $raw_body = ''; |
| 20 | 20 | public $files; |
| 21 | 21 | public $respcode; |
| 22 | - public $status = WPRProtectRequest_V662::STATUS_ALLOWED; | |
| 23 | - public $category = WPRProtectRequest_V662::CATEGORY_NORMAL; | |
| 22 | + public $status = WPRProtectRequest_V676::STATUS_ALLOWED; | |
| 23 | + public $category = WPRProtectRequest_V676::CATEGORY_NORMAL; | |
| 24 | 24 | |
| 25 | 25 | public $wp_user; |
| 26 | 26 | |
| 27 | 27 | private $can_get_raw_body = false; |
| @@ -58,9 +58,9 @@ | ||
| 58 | 58 | const CATEGORY_PRIVATEIP = 80; |
| 59 | 59 | const CATEGORY_GLOBAL_BOT_BLOCKED = 90; |
| 60 | 60 | |
| 61 | 61 | public function __construct($ip_header, $config) { |
| 62 | - $this->ip = WPRProtectUtils_V662::getIP($ip_header); | |
| 62 | + $this->ip = WPRProtectUtils_V676::getIP($ip_header); | |
| 63 | 63 | $this->timestamp = time(); |
| 64 | 64 | $this->get_params = $_GET; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 65 | 65 | $this->cookies = $_COOKIE; |
| 66 | 66 | $this->post_params = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| @@ -140,17 +140,17 @@ | ||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public static function blacklistedCategories() { |
| 143 | 143 | return array( |
| 144 | - WPRProtectRequest_V662::CATEGORY_BOT_BLOCKED, | |
| 145 | - WPRProtectRequest_V662::CATEGORY_COUNTRY_BLOCKED, | |
| 146 | - WPRProtectRequest_V662::CATEGORY_USER_BLACKLISTED, | |
| 147 | - WPRProtectRequest_V662::CATEGORY_GLOBAL_BOT_BLOCKED | |
| 144 | + WPRProtectRequest_V676::CATEGORY_BOT_BLOCKED, | |
| 145 | + WPRProtectRequest_V676::CATEGORY_COUNTRY_BLOCKED, | |
| 146 | + WPRProtectRequest_V676::CATEGORY_USER_BLACKLISTED, | |
| 147 | + WPRProtectRequest_V676::CATEGORY_GLOBAL_BOT_BLOCKED | |
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | public static function whitelistedCategories() { |
| 152 | - return array(WPRProtectRequest_V662::CATEGORY_WHITELISTED); | |
| 152 | + return array(WPRProtectRequest_V676::CATEGORY_WHITELISTED); | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function setRespCode($code) { |
| 156 | 156 | $this->respcode = $code; |
| @@ -189,25 +189,14 @@ | ||
| 189 | 189 | } |
| 190 | 190 | return null; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - private function getContentMediaType($content_type) { | |
| 193 | + private function isJsonContentType($content_type) { | |
| 194 | 194 | if (!is_string($content_type)) { |
| 195 | - return null; | |
| 196 | - } | |
| 197 | - | |
| 198 | - $parts = explode(';', $content_type, 2); | |
| 199 | - $media_type = strtolower(trim($parts[0])); | |
| 200 | - return $media_type !== '' ? $media_type : null; | |
| 201 | - } | |
| 202 | - | |
| 203 | - private function isJsonContentType($content_type) { | |
| 204 | - $media_type = $this->getContentMediaType($content_type); | |
| 205 | - if (!isset($media_type)) { | |
| 206 | 195 | return false; |
| 207 | 196 | } |
| 208 | 197 | |
| 209 | - return preg_match('/^application\/(?:[\w!#$&^.+-]+\+)?json(?:\+oembed)?$/', $media_type) === 1; | |
| 198 | + return preg_match('/(^|\s|,)application\/([\w!#\$&-\^\.\+]+\+)?json(\+oembed)?($|\s|;|,)/i', $content_type) === 1; | |
| 210 | 199 | } |
| 211 | 200 | |
| 212 | 201 | private function normalizeHeaderName($name) { |
| 213 | 202 | if (!is_string($name)) { |
| @@ -497,9 +486,9 @@ | ||
| 497 | 486 | $this->json_params_status = 'raw_body_truncated'; |
| 498 | 487 | return; |
| 499 | 488 | } |
| 500 | 489 | |
| 501 | - $_json_params = WPRProtectUtils_V662::safeDecodeJSON( | |
| 490 | + $_json_params = WPRProtectUtils_V676::safeDecodeJSON( | |
| 502 | 491 | $this->raw_body, |
| 503 | 492 | true, |
| 504 | 493 | $this->max_json_decode_depth |
| 505 | 494 | ); |