Update include tag to be more permissive (#8618)

Merge pull request 8618
This commit is contained in:
Parker Moore 2021-03-27 11:36:12 -04:00 committed by GitHub
parent 6c170f11af
commit 5d01099e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 1 deletions

View File

@ -13,7 +13,7 @@ module Jekyll
!mx.freeze
FULL_VALID_SYNTAX = %r!\A\s*(?:#{VALID_SYNTAX}(?=\s|\z)\s*)*\z!.freeze
VALID_FILENAME_CHARS = %r!^[\w/.-]+$!.freeze
VALID_FILENAME_CHARS = %r!^[\w/.\-()+~\#@]+$!.freeze
INVALID_SEQUENCES = %r![./]{2,}!.freeze
def initialize(tag_name, markup, tokens)

View File

@ -0,0 +1,7 @@
<span id='include-param'>{{include.param}}</span>
<ul id='param-list'>
{% for param in include %}
<li>{{param[0]}} = {{param[1]}}</li>
{% endfor %}
</ul>

View File

@ -907,6 +907,49 @@ class TestTags < JekyllUnitTest
end
end
context "with include file with special characters without params" do
setup do
content = <<~CONTENT
---
title: special characters
---
{% include params@2.0.html %}
CONTENT
create_post(content,
"permalink" => "pretty",
"source" => source_dir,
"destination" => dest_dir,
"read_posts" => true)
end
should "include file with empty parameters" do
assert_match "<span id=\"include-param\"></span>", @result
end
end
context "with include file with special characters with params" do
setup do
content = <<~CONTENT
---
title: special characters
---
{% include params@2.0.html param1="foobar" param2="bazbar" %}
CONTENT
create_post(content,
"permalink" => "pretty",
"source" => source_dir,
"destination" => dest_dir,
"read_posts" => true)
end
should "include file with empty parameters" do
assert_match "<li>param1 = foobar</li>", @result
assert_match "<li>param2 = bazbar</li>", @result
end
end
context "with custom includes directory" do
setup do
content = <<~CONTENT