changeset 101:d74ae33832ae

Fix a bug with the posts source incorrectly escaping regex characters.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 13 Sep 2014 23:31:47 -0700
parents 69d5eecfa449
children 343befeb936f
files piecrust/sources/posts.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/sources/posts.py	Sat Sep 13 23:31:21 2014 -0700
+++ b/piecrust/sources/posts.py	Sat Sep 13 23:31:47 2014 -0700
@@ -93,7 +93,8 @@
                 'slug': '(?P<slug>.*)',
                 'ext': '(?P<ext>.*)'
                 }
-        pattern = self.path_format % regex_repl + '$'
+        path_format_re = re.sub(r'([\-\.])', r'\\\1', self.path_format)
+        pattern = path_format_re % regex_repl + '$'
         m = re.search(pattern, path.replace('\\', '/'))
         if not m:
             raise Exception("Expected to be able to match path with path "