Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Service/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function convertLinks(string $data): string {
$linker = new UrlLinker([
'allowFtpAddresses' => true,
'allowUpperCaseUrlSchemes' => false,
'skipAmbiguousTlds' => true,
'htmlLinkCreator' => static fn ($url)
// Render full url for the link description. Otherwise, potentially malicious query
// params might be hidden.
Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Service/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ public function testLinkDetectionLeavesValidMultibyteTextUnchanged(): void {
self::assertStringContainsString("\u{1F609}", $withLinks);
}

public function testDoNotLinkAmbiguousExtensions(): void {
$urlGenerator = Server::get(IURLGenerator::class);
$request = Server::get(IRequest::class);
$hmacGenerator = $this->createStub(ProxyHmacGenerator::class);

$html = new Html($urlGenerator, $request, $hmacGenerator);
$text = '/home/user/something/text.java';
$result = $html->convertLinks($text);

self::assertStringContainsString('/home/user/something/text.java', $result);
$this->assertStringNotContainsString('http', $result);
}

/**
* @dataProvider parseMailBodyProvider
* @param $expected
Expand Down
Loading