Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve runkit tag's sanitization (#1798)
  • Loading branch information
Zhao-Andy authored and maestromac committed Feb 13, 2019
1 parent 49e3878 commit 48de217
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/liquid_tags/runkit_tag.rb
@@ -1,7 +1,7 @@
class RunkitTag < Liquid::Block
def initialize(tag_name, markup, tokens)
super
@preamble = ActionView::Base.full_sanitizer.sanitize(markup, tags: [])
@preamble = sanitized_preamble(markup)
end

def render(context)
Expand Down Expand Up @@ -64,6 +64,16 @@ def self.script
}, 200);
JAVASCRIPT
end

def sanitized_preamble(markup)
raise StandardError, "Runkit tag is invalid" if markup.ends_with? "\">"

sanitized = ActionView::Base.full_sanitizer.sanitize(markup, tags: [])

raise StandardError, "Runkit tag is invalid" if markup.starts_with? "\""

sanitized
end
end

Liquid::Template.register_tag("runkit", RunkitTag)

0 comments on commit 48de217

Please sign in to comment.