mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-09 13:07:27 +03:00
fix(url): disallowed wonky path (#4386)
This commit is contained in:
parent
c44a76ff17
commit
be51ba17df
3 changed files with 10 additions and 3 deletions
|
@ -74,9 +74,7 @@ class RumbleBridge extends BridgeAbstract
|
|||
$item['timestamp'] = $publishedAt->getTimestamp();
|
||||
}
|
||||
|
||||
if (isset($publishedAt) && $publishedAt > new \DateTimeImmutable('2025-01-31')) {
|
||||
$href = ltrim($href, '/');
|
||||
}
|
||||
$href = ltrim($href, '/');
|
||||
$itemUrl = Url::fromString(self::URI . $href);
|
||||
// Remove tracking parameter in query string
|
||||
$item['uri'] = $itemUrl->withQueryString(null)->__toString();
|
||||
|
|
|
@ -111,6 +111,9 @@ final class Url
|
|||
if (!str_starts_with($path, '/')) {
|
||||
throw new UrlException(sprintf('Path must start with forward slash: %s', $path));
|
||||
}
|
||||
if (str_starts_with($path, '//')) {
|
||||
throw new UrlException(sprintf('Illegal path (too many forward slashes): %s', $path));
|
||||
}
|
||||
$clone = clone $this;
|
||||
$clone->path = $path;
|
||||
return $clone;
|
||||
|
|
|
@ -36,6 +36,12 @@ class UrlTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public function testIllegalPath()
|
||||
{
|
||||
$this->expectException(\UrlException::class);
|
||||
Url::fromString('https://example.com//foo');
|
||||
}
|
||||
|
||||
public function testMutation()
|
||||
{
|
||||
$this->assertSame('http://example.com/foo', (Url::fromString('http://example.com/'))->withPath('/foo')->__toString());
|
||||
|
|
Loading…
Reference in a new issue