Skip to content

Commit

Permalink
Merge pull request #28 from 10up/fix/proper-type-checking
Browse files Browse the repository at this point in the history
Better checking of the file type when determining which files are SVGs
  • Loading branch information
jeffpaul committed Feb 14, 2022
2 parents 8415215 + 44752cf commit 00cb9a8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ public function fix_mime_type_svg( $data = null, $file = null, $filename = null,
*/
public function check_for_svg( $file ) {

if ( $file['type'] === 'image/svg+xml' ) {
$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'] );
$type = ! empty( $wp_filetype['type'] ) ? $wp_filetype['type'] : '';

if ( $type === 'image/svg+xml' ) {
if ( ! $this->sanitize( $file['tmp_name'] ) ) {
$file['error'] = __( "Sorry, this file couldn't be sanitized so for security reasons wasn't uploaded",
'safe-svg' );
Expand Down

0 comments on commit 00cb9a8

Please sign in to comment.