diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-05-21 18:30:41 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-05-21 21:01:20 -0500 |
commit | 9abf1ce535f48fd641b8bfb5083d6086a5d5cb0d (patch) | |
tree | fe06fa47d501296236ce560bb3e26fb6f83ac056 /app/models | |
parent | 3c455a7b819d75ada5f631b683f7b73c9deeae77 (diff) |
make sure only `self`/`self.` & `local`/`local.` tags are marked private & local + treat `:` in tags as `.`
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/tag.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/app/models/tag.rb b/app/models/tag.rb index 47bbfea1d..a6a1445a3 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -73,7 +73,7 @@ class Tag < ApplicationRecord class << self def search_for(term, limit = 5, offset = 0) - pattern = sanitize_sql_like(term.strip) + '%' + pattern = sanitize_sql_like(term.strip.gsub(':', '.')) + '%' Tag.where('lower(name) like lower(?)', pattern) .order(:name) @@ -82,7 +82,7 @@ class Tag < ApplicationRecord end def find_normalized(name) - find_by(name: name.mb_chars.downcase.to_s) + find_by(name: name.mb_chars.gsub(':', '.').downcase.to_s) end def find_normalized!(name) @@ -98,7 +98,7 @@ class Tag < ApplicationRecord end def set_scope - self.private = true if name.starts_with?('self', '_self') - self.local = true if self.private || name.starts_with?('local', '_local') + self.private = true if name.in?(['self', '_self']) || name.starts_with?('self.', '_self.') + self.local = true if self.private || name.in?(['local', '_local']) || name.starts_with?('local.', '_local.') end end |