Catch malformed URI content

Summary:
As seen in https://our.intern.facebook.com/intern/bug/653953588368620/,
the network plugin can crash if content doesn't look like a URI.

Ideally, we'd be more granular in catching this, but for now skipping
that content seems better than crashing the entire plugin page.

Reviewed By: danielbuechele

Differential Revision: D14971610

fbshipit-source-id: 2708e5c0d4d1f584419d24c7dc38438009015565
This commit is contained in:
Pascal Hartig
2019-04-17 10:21:20 -07:00
committed by Facebook Github Bot
parent 614f48dda3
commit c244946be3

View File

@@ -71,7 +71,12 @@ function decodeBody(container: Request | Response): string {
// Data is transferred as base64 encoded bytes to support unicode characters,
// we need to decode the bytes here to display the correct unicode characters.
return decodeURIComponent(escape(body));
try {
return decodeURIComponent(escape(body));
} catch (e) {
console.warn('Discarding malformed body:', escape(body));
return '';
}
}
function decompress(body: string): string {