TagName サニタイズ(#281) (#289)
#281 #281 Merge remote-tracking branch 'origin/main' into feature/281 #281 #281 テストまだ通ってないので要確認 Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #289
This commit was merged in pull request #289.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
class CreateTagNameSanitisationRules < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
create_table :tag_name_sanitisation_rules, id: :integer, primary_key: :priority do |t|
|
||||
t.string :source_pattern, null: false
|
||||
t.string :replacement, null: false
|
||||
t.timestamps
|
||||
t.datetime :discarded_at
|
||||
t.index :source_pattern, unique: true
|
||||
t.index :discarded_at
|
||||
end
|
||||
|
||||
now = ActiveRecord::Base.connection.quote(Time.current)
|
||||
execute <<~SQL
|
||||
INSERT INTO
|
||||
tag_name_sanitisation_rules(priority, source_pattern, replacement, created_at, updated_at)
|
||||
VALUES
|
||||
(10, '\\\\*', '_', #{ now }, #{ now })
|
||||
, (20, '\\\\?', '_', #{ now }, #{ now })
|
||||
, (25, '\\\\/', '_', #{ now }, #{ now })
|
||||
, (30, '_+', '_', #{ now }, #{ now })
|
||||
, (40, '_$', '', #{ now }, #{ now })
|
||||
, (45, '^([^:]+\\\\:)?_', '\\\\1', #{ now }, #{ now })
|
||||
, (50, '^([^:]+\\\\:)?$', '\\\\1null', #{ now }, #{ now })
|
||||
;
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :tag_name_sanitisation_rules
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddDiscardedAtToTagNames < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :tag_names, :discarded_at, :datetime
|
||||
add_index :tag_names, :discarded_at
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddDiscardedAtToWikiPages < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :wiki_pages, :discarded_at, :datetime
|
||||
add_index :wiki_pages, :discarded_at
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user