From 907477b9ca013d3770b5f906789885c116591346 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 15 Mar 2019 22:44:57 +0530 Subject: [PATCH] Escape valid special chars in a site's path name (#7568) Merge pull request 7568 --- features/rendering.feature | 13 +++++++++++++ lib/jekyll/liquid_renderer.rb | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/features/rendering.feature b/features/rendering.feature index 4c4e28f6..0b42d44b 100644 --- a/features/rendering.feature +++ b/features/rendering.feature @@ -5,6 +5,19 @@ Feature: Rendering But I want to make it as simply as possible So render with Liquid and place in Layouts + Scenario: Rendering a site with parentheses in its path name + Given I have a blank site in "omega(beta)" + And I have an "omega(beta)/test.md" page with layout "simple" that contains "Hello World" + And I have an omega(beta)/_includes directory + And I have an "omega(beta)/_includes/head.html" file that contains "Snippet" + And I have a configuration file with "source" set to "omega(beta)" + And I have an omega(beta)/_layouts directory + And I have an "omega(beta)/_layouts/simple.html" file that contains "{% include head.html %}: {{ content }}" + When I run jekyll build --profile + Then I should get a zero exit status + And I should see "Snippet:

Hello World

" in "_site/test.html" + And I should see "_layouts/simple.html" in the build output + Scenario: When receiving bad Liquid Given I have a "index.html" page with layout "simple" that contains "{% include invalid.html %}" And I have a simple layout that contains "{{ content }}" diff --git a/lib/jekyll/liquid_renderer.rb b/lib/jekyll/liquid_renderer.rb index 986b7c5e..33df9d3c 100644 --- a/lib/jekyll/liquid_renderer.rb +++ b/lib/jekyll/liquid_renderer.rb @@ -65,7 +65,9 @@ module Jekyll private def filename_regex - @filename_regex ||= %r!\A(#{source_dir}/|#{theme_dir}/|/*)(.*)!i + @filename_regex ||= begin + %r!\A(#{Regexp.escape(source_dir)}/|#{Regexp.escape(theme_dir.to_s)}/|/*)(.*)!i + end end def new_profile_hash