Fix #2894: Use [[:space:]] instead of \s in regexes.
This commit is contained in:
@@ -233,7 +233,7 @@ class Artist < ApplicationRecord
|
||||
end
|
||||
|
||||
def other_names_array
|
||||
other_names.try(:split, /\s/)
|
||||
other_names.try(:split, /[[:space:]]+/)
|
||||
end
|
||||
|
||||
def other_names_comma
|
||||
|
||||
@@ -48,11 +48,11 @@ class ArtistVersion < ApplicationRecord
|
||||
extend SearchMethods
|
||||
|
||||
def url_array
|
||||
url_string.to_s.scan(/\S+/)
|
||||
url_string.to_s.split(/[[:space:]]+/)
|
||||
end
|
||||
|
||||
def other_names_array
|
||||
other_names.to_s.scan(/\S+/)
|
||||
other_names.to_s.split(/[[:space:]]+/)
|
||||
end
|
||||
|
||||
def urls_diff(version)
|
||||
|
||||
@@ -3,7 +3,7 @@ class Comment < ApplicationRecord
|
||||
|
||||
validate :validate_post_exists, :on => :create
|
||||
validate :validate_creator_is_not_limited, :on => :create
|
||||
validates_format_of :body, :with => /\S/, :message => 'has no content'
|
||||
validates_presence_of :body, :message => "has no content"
|
||||
belongs_to :post
|
||||
belongs_to_creator
|
||||
belongs_to_updater
|
||||
|
||||
@@ -8,13 +8,8 @@ class Dmail < ApplicationRecord
|
||||
|
||||
include Rakismet::Model
|
||||
|
||||
with_options on: :create do
|
||||
validates_presence_of :to_id
|
||||
validates_presence_of :from_id
|
||||
validates_format_of :title, :with => /\S/
|
||||
validates_format_of :body, :with => /\S/
|
||||
validate :validate_sender_is_not_banned
|
||||
end
|
||||
validates_presence_of :title, :body, on: :create
|
||||
validate :validate_sender_is_not_banned, on: :create
|
||||
|
||||
belongs_to :owner, :class_name => "User"
|
||||
belongs_to :to, :class_name => "User"
|
||||
@@ -217,7 +212,7 @@ class Dmail < ApplicationRecord
|
||||
extend SearchMethods
|
||||
|
||||
def validate_sender_is_not_banned
|
||||
if from.is_banned?
|
||||
if from.try(:is_banned?)
|
||||
errors[:base] << "Sender is banned and cannot send messages"
|
||||
return false
|
||||
else
|
||||
|
||||
@@ -18,6 +18,6 @@ class DmailFilter < ApplicationRecord
|
||||
end
|
||||
|
||||
def regexp
|
||||
@regexp ||= Regexp.compile('\b(?:' + words.scan(/\S+/).map {|x| Regexp.escape(x)}.join("|") + ')\b')
|
||||
@regexp ||= /\b#{Regexp.union(words.split(/[[:space:]]+/))}\b/
|
||||
end
|
||||
end
|
||||
|
||||
@@ -108,7 +108,7 @@ class FavoriteGroup < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.normalize_name(name)
|
||||
name.gsub(/\s+/, "_")
|
||||
name.gsub(/[[:space:]]+/, "_")
|
||||
end
|
||||
|
||||
def normalize_name
|
||||
|
||||
@@ -970,7 +970,7 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def clean_fav_string!
|
||||
array = fav_string.scan(/\S+/).uniq
|
||||
array = fav_string.split.uniq
|
||||
self.fav_string = array.join(" ")
|
||||
self.fav_count = array.size
|
||||
update_column(:fav_string, fav_string)
|
||||
@@ -1113,7 +1113,7 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def set_pool_category_pseudo_tags
|
||||
self.pool_string = (pool_string.scan(/\S+/) - ["pool:series", "pool:collection"]).join(" ")
|
||||
self.pool_string = (pool_string.split - ["pool:series", "pool:collection"]).join(" ")
|
||||
|
||||
pool_categories = pools.undeleted.pluck(:category)
|
||||
if pool_categories.include?("series")
|
||||
@@ -1157,7 +1157,7 @@ class Post < ApplicationRecord
|
||||
def fast_count(tags = "", options = {})
|
||||
tags = tags.to_s
|
||||
tags += " rating:s" if CurrentUser.safe_mode?
|
||||
tags += " -status:deleted" if CurrentUser.hide_deleted_posts? && tags !~ /(?:^|\s)(?:-)?status:.+/
|
||||
tags += " -status:deleted" if CurrentUser.hide_deleted_posts? && !Tag.has_metatag?(tags, "status", "-status")
|
||||
tags = Tag.normalize_query(tags)
|
||||
|
||||
# optimize some cases. these are just estimates but at these
|
||||
|
||||
@@ -88,7 +88,7 @@ class PostArchive < ApplicationRecord
|
||||
include ArchiveServiceMethods
|
||||
|
||||
def tag_array
|
||||
tags.scan(/\S+/)
|
||||
tags.split
|
||||
end
|
||||
|
||||
def presenter
|
||||
|
||||
@@ -51,7 +51,7 @@ class PostVersion < ApplicationRecord
|
||||
end
|
||||
|
||||
def tag_array
|
||||
@tag_array ||= tags.scan(/\S+/)
|
||||
@tag_array ||= tags.split
|
||||
end
|
||||
|
||||
def reload
|
||||
|
||||
@@ -179,7 +179,7 @@ class Tag < ApplicationRecord
|
||||
while counts.empty? && n < 1000
|
||||
tag_strings = Post.select_values_sql("select tag_string from posts where created_at >= ?", n.hours.ago)
|
||||
tag_strings.each do |tag_string|
|
||||
tag_string.scan(/\S+/).each do |tag|
|
||||
tag_string.split.each do |tag|
|
||||
counts[tag] ||= 0
|
||||
counts[tag] += 1
|
||||
end
|
||||
|
||||
@@ -239,8 +239,8 @@ class Upload < ApplicationRecord
|
||||
end
|
||||
|
||||
def assign_rating_from_tags
|
||||
if tag_string =~ /(?:\s|^)rating:([qse])/i
|
||||
self.rating = $1.downcase
|
||||
if rating = Tag.has_metatag?(tag_string, :rating)
|
||||
self.rating = rating.downcase
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -234,6 +234,6 @@ class WikiPage < ApplicationRecord
|
||||
end
|
||||
|
||||
def other_names_array
|
||||
other_names.to_s.scan(/\S+/)
|
||||
other_names.to_s.split(/[[:space:]]+/)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,6 +47,6 @@ class WikiPageVersion < ApplicationRecord
|
||||
end
|
||||
|
||||
def other_names_array
|
||||
other_names.to_s.scan(/\S+/)
|
||||
other_names.to_s.split(/[[:space:]]+/)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user