Skip to content

Commit 151e824

Browse files
committed
check non-http urls
1 parent df87aa4 commit 151e824

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Extractor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ public function getUri(): UriInterface
175175
public function resolveUri($uri): UriInterface
176176
{
177177
if (is_string($uri)) {
178+
if (!isHttp($uri)) {
179+
throw new InvalidArgumentException('Uri string must use http or https scheme');
180+
}
181+
178182
$uri = $this->crawler->createUri($uri);
179183
}
180184

src/functions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ function resolveUri(UriInterface $base, UriInterface $uri): UriInterface
6161
->withFragment('');
6262
}
6363

64+
function isHttp(string $uri): bool
65+
{
66+
return (bool) preg_match('#^(https?:|\.|/)#', $src);
67+
}
68+
6469
function resolvePath(string $base, string $path): string
6570
{
6671
if ($path === '') {

0 commit comments

Comments
 (0)