FIX: stop using regex to detect mentions
This commit is contained in:
parent
4ce870c17f
commit
833af461ab
|
@ -52,11 +52,17 @@ class PostAnalyzer
|
||||||
cooked_stripped.css("code").remove
|
cooked_stripped.css("code").remove
|
||||||
cooked_stripped.css(".onebox").remove
|
cooked_stripped.css(".onebox").remove
|
||||||
|
|
||||||
@raw_mentions = cooked_stripped.to_html
|
raw_mentions = cooked_stripped.css('.mention').map do |e|
|
||||||
.scan(PrettyText.mention_matcher)
|
if name = e.inner_text
|
||||||
.flatten
|
name = name[1..-1]
|
||||||
.map(&:downcase)
|
name.downcase! if name
|
||||||
.uniq
|
name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
raw_mentions.compact!
|
||||||
|
raw_mentions.uniq!
|
||||||
|
@raw_mention = raw_mentions
|
||||||
end
|
end
|
||||||
|
|
||||||
# from rack ... compat with ruby 2.2
|
# from rack ... compat with ruby 2.2
|
||||||
|
|
|
@ -72,10 +72,6 @@ module PrettyText
|
||||||
@mutex = Mutex.new
|
@mutex = Mutex.new
|
||||||
@ctx_init = Mutex.new
|
@ctx_init = Mutex.new
|
||||||
|
|
||||||
def self.mention_matcher
|
|
||||||
Regexp.new("\\W@([\\w\\-]{#{SiteSetting.min_username_length},#{SiteSetting.max_username_length}})\\b")
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.app_root
|
def self.app_root
|
||||||
Rails.root
|
Rails.root
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue