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:
15
app/logical/custom_css.rb
Normal file
15
app/logical/custom_css.rb
Normal 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
|
||||
Reference in New Issue
Block a user