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.
This commit is contained in:
Eldritch Cheese
2016-11-26 16:51:01 -05:00
parent ce67da0f80
commit bbdeb32f38

View File

@@ -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