File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -591,6 +591,9 @@ private static function getUriFromGlobals(Swoole\Http\Request $swooleRequest): U
591591 private static function parseHost (string $ httpHost ): array
592592 {
593593 $ parts = parse_url ('// ' . $ httpHost );
594+ if (! isset ($ parts ['host ' ])) {
595+ throw new InvalidArgumentException ('Invalid host: ' . $ httpHost );
596+ }
594597
595598 return [$ parts ['host ' ], $ parts ['port ' ] ?? null ];
596599 }
Original file line number Diff line number Diff line change 2222use Hyperf \Utils \Codec \Xml ;
2323use HyperfTest \HttpMessage \Stub \ParserStub ;
2424use HyperfTest \HttpMessage \Stub \Server \RequestStub ;
25+ use InvalidArgumentException ;
2526use Mockery ;
2627use PHPUnit \Framework \TestCase ;
2728use Psr \Container \ContainerInterface ;
@@ -174,6 +175,10 @@ public function testParseHost()
174175 $ resIPv6 = $ method ->invokeArgs (null , [$ hostStrIPv6 ]);
175176 $ this ->assertSame ('[fe80::a464:1aff:fe88:7b5a] ' , $ resIPv6 [0 ]);
176177 $ this ->assertSame (9502 , $ resIPv6 [1 ]);
178+
179+ $ this ->expectException (InvalidArgumentException::class);
180+ $ this ->expectExceptionMessage ('Invalid host: ' );
181+ $ method ->invokeArgs (null , ['' ]);
177182 }
178183
179184 /**
You can’t perform that action at this time.
0 commit comments