From bbdeb32f38727113b274367c340599bcb9c54014 Mon Sep 17 00:00:00 2001 From: Eldritch Cheese Date: Sat, 26 Nov 2016 16:51:01 -0500 Subject: [PATCH] Escaped regular expressions when using post_url. Previously, the post_url function would give error messages when the post being listed contained special characters for use in regular expressions. These special characters are now escaped using Regexp.escape. --- lib/jekyll/tags/post_url.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index b865cd67..9b4203d6 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -14,7 +14,8 @@ module Jekyll "'#{name}' does not contain valid date and/or title." end - @name_regex = %r!^_posts/#{path}#{date}-#{slug}\.[^.]+| + escaped_slug = Regexp.escape(slug) + @name_regex = %r!^_posts/#{path}#{date}-#{escaped_slug}\.[^.]+| ^#{path}_posts/?#{date}-#{slug}\.[^.]+!x end