Skip to content

Commit

Permalink
Merge pull request #63 from matthewd/no-slow
Browse files Browse the repository at this point in the history
Avoid another pathological input
  • Loading branch information
matthewd committed Jun 1, 2016
2 parents 334044b + 36bcf38 commit 24353cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rails_autolink/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { ']' => '[', ')' => '(', '}' => '{' }

Expand Down
4 changes: 3 additions & 1 deletion test/test_rails_autolink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 24353cb

Please sign in to comment.