From 0c0b5ef672a958c418abc9b973a9d1516c6e8456 Mon Sep 17 00:00:00 2001 From: Mikael Roos Date: Tue, 28 Apr 2015 14:22:38 +0200 Subject: [PATCH] allow space in image filename by default, fix #91 --- REVISION.md | 1 + webroot/img.php | 4 ++-- webroot/img_config.php | 4 ++-- webroot/imgd.php | 4 ++-- webroot/imgp.php | 4 ++-- webroot/imgs.php | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/REVISION.md b/REVISION.md index 6f49275..22bd89c 100644 --- a/REVISION.md +++ b/REVISION.md @@ -8,6 +8,7 @@ Revision history v0.7.0.x (latest) ------------------------------------- +* Allow space in filename by using `urlencode()` and allow space as valid filenam character. fix 91. * Support redirections for remote images, fix #87, fix #90. * Improving usage of Travis and Scrutinizer. * Naming cache-file using md5 for remote images, fix #86. diff --git a/webroot/img.php b/webroot/img.php index b270be3..c280f79 100644 --- a/webroot/img.php +++ b/webroot/img.php @@ -340,13 +340,13 @@ if (isset($shortcut) /** * src - the source image file. */ -$srcImage = get('src') +$srcImage = urldecode(get('src')) or errorPage('Must set src-attribute.'); // Check for valid/invalid characters $imagePath = getConfig('image_path', __DIR__ . '/img/'); $imagePathConstraint = getConfig('image_path_constraint', true); -$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\.:]+$#'); +$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \.:]+$#'); preg_match($validFilename, $srcImage) or errorPage('Filename contains invalid characters.'); diff --git a/webroot/img_config.php b/webroot/img_config.php index 754bc67..633e134 100644 --- a/webroot/img_config.php +++ b/webroot/img_config.php @@ -94,10 +94,10 @@ return array( * A regexp for validating characters in the image or alias filename. * * Default value: - * valid_filename: '#^[a-z0-9A-Z-/_\.:]+$#' + * valid_filename: '#^[a-z0-9A-Z-/_ \.:]+$#' * valid_aliasname: '#^[a-z0-9A-Z-_]+$#' */ - //'valid_filename' => '#^[a-z0-9A-Z-/_\.:]+$#', + //'valid_filename' => '#^[a-z0-9A-Z-/_ \.:]+$#', //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#', diff --git a/webroot/imgd.php b/webroot/imgd.php index d1080f5..2d3751c 100644 --- a/webroot/imgd.php +++ b/webroot/imgd.php @@ -3382,13 +3382,13 @@ if (isset($shortcut) /** * src - the source image file. */ -$srcImage = get('src') +$srcImage = urldecode(get('src')) or errorPage('Must set src-attribute.'); // Check for valid/invalid characters $imagePath = getConfig('image_path', __DIR__ . '/img/'); $imagePathConstraint = getConfig('image_path_constraint', true); -$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\.:]+$#'); +$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \.:]+$#'); preg_match($validFilename, $srcImage) or errorPage('Filename contains invalid characters.'); diff --git a/webroot/imgp.php b/webroot/imgp.php index 89f87c5..4f99e9c 100644 --- a/webroot/imgp.php +++ b/webroot/imgp.php @@ -3382,13 +3382,13 @@ if (isset($shortcut) /** * src - the source image file. */ -$srcImage = get('src') +$srcImage = urldecode(get('src')) or errorPage('Must set src-attribute.'); // Check for valid/invalid characters $imagePath = getConfig('image_path', __DIR__ . '/img/'); $imagePathConstraint = getConfig('image_path_constraint', true); -$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\.:]+$#'); +$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \.:]+$#'); preg_match($validFilename, $srcImage) or errorPage('Filename contains invalid characters.'); diff --git a/webroot/imgs.php b/webroot/imgs.php index d1080f5..2d3751c 100644 --- a/webroot/imgs.php +++ b/webroot/imgs.php @@ -3382,13 +3382,13 @@ if (isset($shortcut) /** * src - the source image file. */ -$srcImage = get('src') +$srcImage = urldecode(get('src')) or errorPage('Must set src-attribute.'); // Check for valid/invalid characters $imagePath = getConfig('image_path', __DIR__ . '/img/'); $imagePathConstraint = getConfig('image_path_constraint', true); -$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_\.:]+$#'); +$validFilename = getConfig('valid_filename', '#^[a-z0-9A-Z-/_ \.:]+$#'); preg_match($validFilename, $srcImage) or errorPage('Filename contains invalid characters.');