Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
567:a65f04ddbea2 | 568:6b6c5442c790 |
---|---|
1 import re | 1 import re |
2 import json | 2 import json |
3 import time | 3 import time |
4 import os.path | 4 import os.path |
5 import urllib.parse | |
5 import codecs | 6 import codecs |
6 import hashlib | 7 import hashlib |
7 import logging | 8 import logging |
8 import collections | 9 import collections |
9 import yaml | 10 import yaml |
143 | 144 |
144 # Make sure the site root starts and ends with a slash. | 145 # Make sure the site root starts and ends with a slash. |
145 if not sitec['root'].startswith('/'): | 146 if not sitec['root'].startswith('/'): |
146 raise ConfigurationError("The `site/root` setting must start " | 147 raise ConfigurationError("The `site/root` setting must start " |
147 "with a slash.") | 148 "with a slash.") |
148 sitec['root'] = sitec['root'].rstrip('/') + '/' | 149 sitec['root'] = urllib.parse.quote(sitec['root'].rstrip('/') + '/') |
149 | 150 |
150 # Cache auto-format regexes. | 151 # Cache auto-format regexes. |
151 if not isinstance(sitec['auto_formats'], dict): | 152 if not isinstance(sitec['auto_formats'], dict): |
152 raise ConfigurationError("The 'site/auto_formats' setting must be " | 153 raise ConfigurationError("The 'site/auto_formats' setting must be " |
153 "a dictionary.") | 154 "a dictionary.") |