Skip to content

Commit

Permalink
Sanitize input before outputing it
Browse files Browse the repository at this point in the history
XSS is a nasty hack, we always need to sanitize user input.

Fixes #152
  • Loading branch information
nitriques committed Oct 27, 2016
1 parent fa71743 commit dfa7703
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function __errorHandler($errno=NULL, $errstr, $errfile=NULL, $errline=NULL, $err
$param->background,
$param->file,
(bool)$param->external,
$_GET['param']
General::sanitize($_GET['param'])
), E_NOTICE, true
);
}
Expand Down Expand Up @@ -325,8 +325,9 @@ function __errorHandler($errno=NULL, $errstr, $errfile=NULL, $errline=NULL, $err
) {
// Guess not, return 404.
Page::renderStatusCode(Page::HTTP_STATUS_NOT_FOUND);
trigger_error(sprintf('Image <code>%s</code> could not be found.', str_replace(DOCROOT, '', $original_file)), E_USER_ERROR);
echo sprintf('Image <code>%s</code> could not be found.', str_replace(DOCROOT, '', $original_file));
$safeOriginalFile = General::sanitize(str_replace(DOCROOT, '', $original_file));
trigger_error(sprintf('Image <code>%s</code> could not be found.', $safeOriginalFile, E_USER_ERROR));
echo sprintf('Image <code>%s</code> could not be found.', $safeOriginalFile);
exit;
}
$meta = Image::getMetaInformation($image_path);
Expand Down

0 comments on commit dfa7703

Please sign in to comment.