diff piecrust/app.py @ 568:6b6c5442c790

bug: Correctly handle root URLs with special characters. The `site/root` setting is now pre-escaped to get a correct URL, and routing excludes it from escaping. Add unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 13 Oct 2015 22:50:38 -0700
parents 624559e72d3b
children 9ccc933ac2c7
line wrap: on
line diff
--- a/piecrust/app.py	Tue Oct 13 22:46:05 2015 -0700
+++ b/piecrust/app.py	Tue Oct 13 22:50:38 2015 -0700
@@ -2,6 +2,7 @@
 import json
 import time
 import os.path
+import urllib.parse
 import codecs
 import hashlib
 import logging
@@ -145,7 +146,7 @@
         if not sitec['root'].startswith('/'):
             raise ConfigurationError("The `site/root` setting must start "
                                      "with a slash.")
-        sitec['root'] = sitec['root'].rstrip('/') + '/'
+        sitec['root'] = urllib.parse.quote(sitec['root'].rstrip('/') + '/')
 
         # Cache auto-format regexes.
         if not isinstance(sitec['auto_formats'], dict):