From ece0d25c2b64b1bc1f1b4b6343a7f5b909d75f06 Mon Sep 17 00:00:00 2001 From: Henrik Nygren Date: Wed, 25 Feb 2015 14:28:08 +0200 Subject: Fix a backtracking problem in String#truncate_words Fixes #19070. --- activesupport/lib/active_support/core_ext/string/filters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index 096292dc58..b88976eab2 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -93,7 +93,7 @@ class String def truncate_words(words_count, options = {}) sep = options[:separator] || /\s+/ sep = Regexp.escape(sep.to_s) unless Regexp === sep - if self =~ /\A((?:.+?#{sep}){#{words_count - 1}}.+?)#{sep}.*/m + if self =~ /\A((?>.+?#{sep}){#{words_count - 1}}.+?)#{sep}.*/m $1 + (options[:omission] || '...') else dup -- cgit v1.2.3