Permalink
Browse files

Merge pull request #63 from matthewd/no-slow

Avoid another pathological input
  • Loading branch information...
2 parents 334044b + 36bcf38 commit 24353cbfe54d53e732b0d5e05e4f829e4528a794 @matthewd matthewd committed Jun 1, 2016
Showing with 4 additions and 2 deletions.
  1. +1 −1 lib/rails_autolink/helpers.rb
  2. +3 −1 test/test_rails_autolink.rb
@@ -79,7 +79,7 @@ def auto_link(text, *args, &block) #link = :all, html = {}, &block)
AUTO_LINK_CRE = [/<[^>]+$/, /^[^>]*>/, /<a\b.*?>/i, /<\/a>/i]
AUTO_EMAIL_LOCAL_RE = /[\w.!#\$%&'*\/=?^`{|}~+-]/
- AUTO_EMAIL_RE = /[\w.!#\$%+-]\.?#{AUTO_EMAIL_LOCAL_RE}*@[\w-]+(?:\.[\w-]+)+/
+ AUTO_EMAIL_RE = /(?<!#{AUTO_EMAIL_LOCAL_RE})[\w.!#\$%+-]\.?#{AUTO_EMAIL_LOCAL_RE}*@[\w-]+(?:\.[\w-]+)+/
BRACKETS = { ']' => '[', ')' => '(', '}' => '{' }
@@ -331,10 +331,12 @@ def test_autolink_with_trailing_amp_on_link
end
def test_auto_link_does_not_timeout_when_parsing_odd_email_input
- inputs = %w(
+ inputs = %W(
foo@...................................
foo@........................................
foo@.............................................
+
+ #{'foo' * 20000}@
)
inputs.each do |input|

0 comments on commit 24353cb

Please sign in to comment.