SECURITY: Prevent XSS in local oneboxes (#20008)

Co-authored-by: OsamaSayegh <asooomaasoooma90@gmail.com>
This commit is contained in:
Bianca Nenciu
2023-01-25 19:17:21 +02:00
committed by GitHub
parent f55e0fe791
commit c186a46910
3 changed files with 97 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
# frozen_string_literal: true
class TriggerPostRebakeLocalOneboxXss < ActiveRecord::Migration[7.0]
def up
val =
DB.query_single(
"SELECT value FROM site_settings WHERE name = 'content_security_policy'",
).first
return if val == nil || val == "t"
DB.exec(<<~SQL)
UPDATE posts
SET baked_version = NULL
WHERE cooked LIKE '%<a href=%'
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end