Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix raw tag (#1215)
* Fix raw tag

* Remove constant first to prevent warning
  • Loading branch information
Zhao-Andy authored and benhalpern committed Nov 29, 2018
1 parent 3af90f1 commit 32ed3ce
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/liquid_tags/raw_tag.rb
@@ -0,0 +1,8 @@
module Liquid
class Raw < Block
remove_const(:FullTokenPossiblyInvalid) if defined?(FullTokenPossiblyInvalid)
FullTokenPossiblyInvalid = /\A(.*)#{TagStart}\s*(\w+)\s*#{TagEnd}\z/om
end

Template.register_tag("raw", Raw)
end
5 changes: 4 additions & 1 deletion app/views/pages/bounty.html.erb
Expand Up @@ -81,7 +81,10 @@
'Antony Garand',
'Rahul PS',
'Gids Goldberg',
] %>
'Mathieu Paturel',
'Benoit C么t茅-Jodoin',
'Nicolas Verdier',
] %>
<% hunters.shuffle.each do |hunter| %>
<li><%= hunter %></li>
<%end %>
Expand Down
8 changes: 8 additions & 0 deletions spec/liquid_tags/raw_tag_spec.rb
@@ -0,0 +1,8 @@
require "rails_helper"

RSpec.describe Liquid::Raw, type: :liquid_template do
it "does not allow non whitespace characters in between the tags" do
invalid_markdown = '<img src="x" class="before{% raw %}inside{% endraw ">%}rawafter"onerror=alert(document.domain) '
expect { Liquid::Template.parse(invalid_markdown) }.to raise_error(StandardError)
end
end

0 comments on commit 32ed3ce

Please sign in to comment.