Skip to content

Commit

Permalink
Filename could contain invalid characters that could be used for XSS #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Jul 25, 2023
1 parent 94faa46 commit a9955bc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion adm_program/system/classes/StringUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public static function strIsValidFileName($filename, $checkExtension = true)
(!self::strValidCharacters($filename, 'file') && $checkExtension) ||
(!self::strValidCharacters($filename, 'folder') && !$checkExtension)
) {
throw new AdmException('SYS_FILENAME_INVALID', array(self::strStripTags($filename)));
throw new AdmException('SYS_FILENAME_INVALID', array(SecurityUtils::encodeHTML(self::strStripTags($filename))));
}

if ($checkExtension) {
Expand Down
2 changes: 2 additions & 0 deletions adm_program/system/classes/UploadHandlerDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ protected function handle_file_upload($uploadedFile, $name, $size, $type, $error
);
}
} catch (AdmException $e) {
// remove XSS from filename before the name will be shown in the error message
$file->name = SecurityUtils::encodeHTML(StringUtils::strStripTags($file->name));
$file->error = $e->getText();

try {
Expand Down
2 changes: 2 additions & 0 deletions adm_program/system/classes/UploadHandlerPhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ protected function handle_file_upload($uploadedFile, $name, $size, $type, $error
throw new AdmException('PHO_PHOTO_PROCESSING_ERROR');
}
} catch (AdmException $e) {
// remove XSS from filename before the name will be shown in the error message
$file->name = SecurityUtils::encodeHTML(StringUtils::strStripTags($file->name));
$file->error = $e->getText();

try {
Expand Down

0 comments on commit a9955bc

Please sign in to comment.