Skip to content

Commit

Permalink
Merge pull request #73 from shinriyo/patch-4
Browse files Browse the repository at this point in the history
check valid xml before parse
  • Loading branch information
lijy91 authored Sep 13, 2024
2 parents 6a8c4fc + 5b2ec32 commit 38913da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/src/minio_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,14 @@ void validate(MinioResponse response, {int? expect}) {
if (response.body.isEmpty) {
error = Error(response.reasonPhrase, null, response.reasonPhrase, null);
} else {
final body = xml.XmlDocument.parse(response.body);
error = Error.fromXml(body.rootElement);
// check valid xml
if (response.body.startWith('<?xml')) {
final body = xml.XmlDocument.parse(response.body);
error = Error.fromXml(body.rootElement);
} else {
// not valid xml
error = Error(response.reasonPhrase, null, response.reasonPhrase, null);
}
}

throw MinioS3Error(error?.message, error, response);
Expand Down

0 comments on commit 38913da

Please sign in to comment.