diff --git a/app/Util/HtmlContentFilter.php b/app/Util/HtmlContentFilter.php
index 08dde7048..182f6e635 100644
--- a/app/Util/HtmlContentFilter.php
+++ b/app/Util/HtmlContentFilter.php
@@ -45,6 +45,11 @@ class HtmlContentFilter
$badIframes = $xPath->query('//*[' . static::xpathContains('@src', 'data:') . '] | //*[' . static::xpathContains('@src', 'javascript:') . '] | //*[@srcdoc]');
static::removeNodes($badIframes);
+ // Remove tags hiding JavaScript or data uris in values attribute.
+ // For example, SVG animate tag can exploit javascript in values.
+ $badValuesTags = $xPath->query('//*[' . static::xpathContains('@values', 'data:') . '] | //*[' . static::xpathContains('@values', 'javascript:') . ']');
+ static::removeNodes($badValuesTags);
+
// Remove elements with a xlink:href attribute
// Used in SVG but deprecated anyway, so we'll be a bit more heavy-handed here.
$xlinkHrefAttributes = $xPath->query('//@*[contains(name(), \'xlink:href\')]');
diff --git a/tests/Entity/PageContentTest.php b/tests/Entity/PageContentTest.php
index d433c8b88..f88e4d513 100644
--- a/tests/Entity/PageContentTest.php
+++ b/tests/Entity/PageContentTest.php
@@ -325,11 +325,14 @@ class PageContentTest extends TestCase
$pageView->assertDontSee('abc123abc123');
}
- public function test_svg_xlink_hrefs_are_removed()
+ public function test_svg_script_usage_is_removed()
{
$checks = [
'',
'',
+ '',
+ '',
+ '',
];
$this->asEditor();
@@ -341,9 +344,11 @@ class PageContentTest extends TestCase
$pageView = $this->get($page->getUrl());
$pageView->assertStatus(200);
- $this->withHtml($pageView)->assertElementNotContains('.page-content', 'alert');
- $this->withHtml($pageView)->assertElementNotContains('.page-content', 'xlink:href');
- $this->withHtml($pageView)->assertElementNotContains('.page-content', 'application/xml');
+ $html = $this->withHtml($pageView);
+ $html->assertElementNotContains('.page-content', 'alert');
+ $html->assertElementNotContains('.page-content', 'xlink:href');
+ $html->assertElementNotContains('.page-content', 'application/xml');
+ $html->assertElementNotContains('.page-content', 'javascript');
}
}