From c244946be3aa7707b5c59f4988be1ab5547d3fb2 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 17 Apr 2019 10:21:20 -0700 Subject: [PATCH] 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 --- src/plugins/network/RequestDetails.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/network/RequestDetails.js b/src/plugins/network/RequestDetails.js index 78bdaa6b1..933fa7769 100644 --- a/src/plugins/network/RequestDetails.js +++ b/src/plugins/network/RequestDetails.js @@ -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 {