Prevent people from setting STATIC_PATHS to a str

Previously you could accidentally set for example site/css and pelican would iterate through the string and attempt to copy '/' into your output.
This commit is contained in:
Dave King 2013-01-12 19:08:24 +00:00 committed by Alexis Métaireau
commit bd54cb1b88
2 changed files with 26 additions and 0 deletions

View file

@ -234,4 +234,14 @@ def configure_settings(settings):
settings['FILENAME_METADATA'] = (
_DEFAULT_CONFIG['FILENAME_METADATA'])
# Save people from accidentally setting site/css vs [site/css]
path_keys = ['STATIC_PATHS', 'THEME_STATIC_PATHS']
for PATH_KEY in filter(lambda k: k in settings, path_keys):
if isinstance(settings[PATH_KEY], six.string_types):
logger.warn("Detected misconfiguration with %s setting (must "
"be a list of paths), falling back to the default"
% PATH_KEY)
settings[PATH_KEY] = \
_DEFAULT_CONFIG[PATH_KEY]
return settings