Skip to content

Commit

Permalink
Properly catching when XML-file cannot be parsed; unifying format of …
Browse files Browse the repository at this point in the history
…results
  • Loading branch information
gudmdharalds committed Jan 4, 2019
1 parent 57b5399 commit fe658fd
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions svg-scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,14 @@ function sysexit(
if ( false === $svg_file ) {
$results['totals']['errors']++;

$results[ 'files' ][ $file_name ][] = array(
'status' => false,
'issues' => 'File specified could not be read (' . $file_name . ')',
$results['files'][ $file_name ][] = array(
'errors' => 1,
'messages' => array(
array(
'message' => 'File specified could not be read (' . $file_name . ')',
'line' => null,
),
),
);

continue;
Expand All @@ -132,6 +137,26 @@ function sysexit(
);
}

/*
* Could not sanitize the file.
*/
else if (
( '' === $sanitize_status ) ||
( false === $sanitize_status )
) {
$results['totals']['errors']++;

$results['files'][ $file_name ] = array(
'errors' => 1,
'messages' => array(
array(
'message' => 'Unable to sanitize file \'' . $file_name . '\'' ,
'line' => null,
)
),
);
}

/*
* If we find issues, note it and update statistics.
*/
Expand Down

0 comments on commit fe658fd

Please sign in to comment.