Fix #4678: Validate custom CSS.

* Make it an error to add invalid custom CSS to your account.
* Add a fix script to remove custom CSS from all accounts with invalid CSS.
This commit is contained in:
evazion
2022-01-15 23:20:15 -06:00
parent c455c08b2c
commit acf565be7b
8 changed files with 70 additions and 2 deletions

15
app/logical/custom_css.rb Normal file
View File

@@ -0,0 +1,15 @@
class CustomCss
attr_reader :css
def initialize(css)
@css = css
end
def valid?
css.blank? || parsed_css.none? { |node| node[:node] == :error }
end
def parsed_css
@parsed_css ||= Crass.parse(css, preserve_comments: true)
end
end