aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dag <me@dvikan.no> 2025-01-03 05:40:30 +0100
committerGravatar GitHub <noreply@github.com> 2025-01-03 05:40:30 +0100
commitbe51ba17df892fde0c371c181425dd636f0f4d37 (patch)
treeca53f2f97628649d0d9abe69a46ea650e154ee3b
parentc44a76ff17833709d9bb336778fdcfd159f620b4 (diff)
downloadrss-bridge-be51ba17df892fde0c371c181425dd636f0f4d37.tar.gz
rss-bridge-be51ba17df892fde0c371c181425dd636f0f4d37.tar.zst
rss-bridge-be51ba17df892fde0c371c181425dd636f0f4d37.zip
fix(url): disallowed wonky path (#4386)
Diffstat (limited to '')
-rw-r--r--bridges/RumbleBridge.php4
-rw-r--r--lib/url.php3
-rw-r--r--tests/UrlTest.php6
3 files changed, 10 insertions, 3 deletions
diff --git a/bridges/RumbleBridge.php b/bridges/RumbleBridge.php
index 11755b51..c1a565bb 100644
--- a/bridges/RumbleBridge.php
+++ b/bridges/RumbleBridge.php
@@ -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();
diff --git a/lib/url.php b/lib/url.php
index 993fef96..9a1b59ad 100644
--- a/lib/url.php
+++ b/lib/url.php
@@ -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;
diff --git a/tests/UrlTest.php b/tests/UrlTest.php
index d45f319b..72b9ac4c 100644
--- a/tests/UrlTest.php
+++ b/tests/UrlTest.php
@@ -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());