From 93200ac057cf4483a18417434fabc7e36a7a6600 Mon Sep 17 00:00:00 2001 From: xboard Date: Sat, 13 Apr 2024 03:23:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=9C=AA=E6=90=BA=E5=B8=A6Content-Type?= =?UTF-8?q?=E7=9A=84=E8=AF=B7=E6=B1=82=E5=A4=B4=E7=9A=84=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=B8=8A=E6=8A=A5=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V1/Server/UniProxyController.php | 10 ++++---- composer.json | 11 ++++++++- patches/Http.patch | 23 +++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 patches/Http.patch diff --git a/app/Http/Controllers/V1/Server/UniProxyController.php b/app/Http/Controllers/V1/Server/UniProxyController.php index 7fd49c2..d43d96e 100644 --- a/app/Http/Controllers/V1/Server/UniProxyController.php +++ b/app/Http/Controllers/V1/Server/UniProxyController.php @@ -9,6 +9,7 @@ use App\Utils\CacheKey; use App\Utils\Helper; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Validator; class UniProxyController extends Controller { @@ -33,10 +34,11 @@ class UniProxyController extends Controller // 后端提交数据 public function push(Request $request) { - $data = $request->validate([ - "*.0" => 'integer', - "*.1" => 'integer' - ]); + $res = json_decode(get_request_content(), true); + $data = Validator::make($res, [ + '*.0' => 'integer', + '*.1' => 'integer', + ])->validate(); $nodeType = $request->input('node_type'); $nodeId = $request->input('node_id'); diff --git a/composer.json b/composer.json index 41faf9b..bfccc63 100755 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "require": { "php": "^8.1", "cedar2025/http-foundation": "6.4.x-dev", + "cweagans/composer-patches": "^1.7", "doctrine/dbal": "^3.7", "firebase/php-jwt": "^6.3", "google/cloud-storage": "^1.35", @@ -45,11 +46,19 @@ "config": { "optimize-autoloader": true, "preferred-install": "dist", - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "cweagans/composer-patches": true + } }, "extra": { "laravel": { "dont-discover": [] + }, + "patches": { + "joanhey/adapterman": { + "http": "patches/Http.patch" + } } }, "autoload": { diff --git a/patches/Http.patch b/patches/Http.patch new file mode 100644 index 0000000..87b842e --- /dev/null +++ b/patches/Http.patch @@ -0,0 +1,23 @@ +diff --git a/src/Http.php b/src/Http.php +index 6c6cb16..f1a7f3f 100644 +--- a/src/Http.php ++++ b/src/Http.php +@@ -680,7 +680,7 @@ + } + + // Parse $_POST. +- if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['CONTENT_TYPE']) { ++ if ($_SERVER['REQUEST_METHOD'] === 'POST') { + switch ($_SERVER['CONTENT_TYPE']) { + case 'multipart/form-data': + static::parseUploadFiles($http_body, $http_post_boundary); +@@ -691,6 +691,8 @@ + case 'application/x-www-form-urlencoded': + \parse_str($http_body, $_POST); + break; ++ default: ++ $_POST = \json_decode($http_body, true) ?? []; + } +- } ++ } + } \ No newline at end of file