mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: InlineOneboxer watched word censor error (#16921)
In 7328a2bfb0 we changed the
InlineOneboxer#onebox_for method to run the title of the
onebox through WatchedWord#censor_text. However, it is
allowable for the title to be nil, which was causing this
error in production:
> NoMethodError : undefined method gsub for nil:NilClass
We just need to check whether the title is nil before trying
to censor it.
This commit is contained in:
@@ -107,8 +107,14 @@ class InlineOneboxer
|
||||
)
|
||||
end
|
||||
end
|
||||
onebox = { url: url, title: title && Emoji.gsub_emoji_to_unicode(title) }
|
||||
onebox[:title] = WordWatcher.censor_text(onebox[:title])
|
||||
|
||||
title = title && Emoji.gsub_emoji_to_unicode(title)
|
||||
if title.present?
|
||||
title = WordWatcher.censor_text(title)
|
||||
end
|
||||
|
||||
onebox = { url: url, title: title }
|
||||
|
||||
Discourse.cache.write(cache_key(url), onebox, expires_in: 1.day) if !opts[:skip_cache]
|
||||
onebox
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user