Stop scrubbing after first regexp timeout

This commit is contained in:
Zacharias Dyna Knudsen
2026-03-20 12:13:17 +01:00
parent 8479be3976
commit b0fa6525fe
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -20,12 +20,13 @@ class AutoLinkScrubber < Loofah::Scrubber
def initialize
@direction = :top_down
@regexp_timeout_reported = false
end
def scrub(node)
return Loofah::Scrubber::STOP if EXCLUDED_ELEMENTS.include?(node.name)
if node.text?
if node.text? && !@regexp_timeout_reported
replacement = autolink_text_node(node)
node.replace(replacement) if replacement
end
@@ -73,6 +74,7 @@ class AutoLinkScrubber < Loofah::Scrubber
links
rescue Regexp::TimeoutError => error
Sentry.capture_exception error if Fizzy.saas?
@regexp_timeout_reported = true
[]
end