Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
3af90f1
commit 32ed3ce
Showing
3 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |