diff --git a/lib/Service/Html.php b/lib/Service/Html.php index 5832263655..1376d88d7d 100755 --- a/lib/Service/Html.php +++ b/lib/Service/Html.php @@ -154,6 +154,7 @@ public function sanitizeHtmlMailBody(int $messageId, string $mailBody, array $in $config->set('Filter.ExtractStyleBlocks.TidyImpl', false); $config->set('CSS.AllowTricky', true); $config->set('CSS.Proprietary', true); + $config->set('Attr.EnableID', true); // Disable the cache since ownCloud has no really appcache // TODO: Fix this - requires https://github.com/owncloud/core/issues/10767 to be fixed diff --git a/tests/Unit/Service/HtmlTest.php b/tests/Unit/Service/HtmlTest.php index 9813a31823..c646f8c265 100644 --- a/tests/Unit/Service/HtmlTest.php +++ b/tests/Unit/Service/HtmlTest.php @@ -246,4 +246,15 @@ public function testSanitizeStyleSheet() { $sanitizedStyleSheet = $html->sanitizeStyleSheet($styleSheet); self::assertSame($expected, $sanitizedStyleSheet); } + + public function testSanitizeHtmlMailBodyPreservesId(): void { + $urlGenerator = $this->createStub(IURLGenerator::class); + $request = $this->createStub(IRequest::class); + $hmacGenerator = $this->createStub(ProxyHmacGenerator::class); + + $html = new Html($urlGenerator, $request, $hmacGenerator); + $result = $html->sanitizeHtmlMailBody(42, '

hello

', []); + + $this->assertStringContainsString('id="target"', $result); + } }