diff --git a/lib/Service/HtmlPurify/TransformURLScheme.php b/lib/Service/HtmlPurify/TransformURLScheme.php
index ccaebdb3de..9efcdefd5d 100644
--- a/lib/Service/HtmlPurify/TransformURLScheme.php
+++ b/lib/Service/HtmlPurify/TransformURLScheme.php
@@ -116,7 +116,7 @@ private function filterHttpFtp(&$uri, $context) {
}
// Get the HTML attribute
- $element = $context->get('CurrentAttr');
+ $element = $context->exists('CurrentAttr') ? $context->get('CurrentAttr') : null;
// If element is of type "href" it is most likely a link that should get redirected
// otherwise it's an element that we send through our proxy