Skip to content

Commit

Permalink
[ticket/13568] Validate imagick path as readable absolute path
Browse files Browse the repository at this point in the history
PHPBB3-13568
  • Loading branch information
marc1706 committed Feb 2, 2015
1 parent 7273591 commit e12ab04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions phpBB/adm/index.php
Expand Up @@ -457,6 +457,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
break;

// Absolute path
case 'script_path_readable':
case 'script_path':
if (!$cfg_array[$config_name])
{
Expand All @@ -483,6 +484,18 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)

$cfg_array[$config_name] = trim($destination);

// Make sure that path is readable
if ($config_definition['validate'] === 'script_path_readable')
{
if (!file_exists($cfg_array[$config_name]))
{
$error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]);
}
else if (!is_dir($cfg_array[$config_name]))
{
$error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]);
}
}
break;

// Absolute path
Expand Down
2 changes: 1 addition & 1 deletion phpBB/includes/acp/acp_attachments.php
Expand Up @@ -127,7 +127,7 @@ function main($id, $mode)
'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
'img_imagick' => array('lang' => 'IMAGICK_PATH', 'validate' => 'path', 'type' => 'text:20:200', 'explain' => true, 'append' => '&nbsp;&nbsp;<span>[ <a href="' . $this->u_action . '&amp;action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'),
'img_imagick' => array('lang' => 'IMAGICK_PATH', 'validate' => 'script_path_readable', 'type' => 'text:20:200', 'explain' => true, 'append' => '&nbsp;&nbsp;<span>[ <a href="' . $this->u_action . '&amp;action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'),
'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']),
)
Expand Down

0 comments on commit e12ab04

Please sign in to comment.