Merge pull request #1302 from Doflatango/fix/get_favicons_exception

Catch and ignore utf8 format exception in getFavicons()
This commit is contained in:
Lorenzo Pichilli 2022-10-13 19:53:55 +02:00 committed by GitHub
commit 741eb3964a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -1096,13 +1096,18 @@ class InAppWebViewController {
}
if (manifestFound) {
Map<String, dynamic> manifest =
json.decode(await manifestResponse!.transform(Utf8Decoder()).join());
if (manifest.containsKey("icons")) {
for (Map<String, dynamic> icon in manifest["icons"]) {
favicons.addAll(_createFavicons(webviewUrl, assetPathBase,
icon["src"], icon["rel"], icon["sizes"], true));
try {
Map<String, dynamic> manifest =
json.decode(await manifestResponse!.transform(Utf8Decoder()).join());
if (manifest.containsKey("icons")) {
for (Map<String, dynamic> icon in manifest["icons"]) {
favicons.addAll(_createFavicons(webviewUrl, assetPathBase,
icon["src"], icon["rel"], icon["sizes"], true));
}
}
} on FormatException catch (_) {
/// The [manifestResponse] might not has a valid JSON string, catch and
/// ignore the error
}
}