From ac135c9fa0e7d06b2b0912061538b989fd06799e Mon Sep 17 00:00:00 2001 From: Andres Sebastian Rudqvist Date: Sat, 11 Apr 2020 22:32:53 -0500 Subject: [PATCH 1/4] =?UTF-8?q?Add=20try-catch=20to=20the=20footer=20parsi?= =?UTF-8?q?ng=20methods=E2=80=94issue=20836.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/framework/footer.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/framework/footer.js b/src/components/framework/footer.js index 59d07601f..efbe55cd7 100644 --- a/src/components/framework/footer.js +++ b/src/components/framework/footer.js @@ -162,8 +162,18 @@ export const getAcknowledgments = (metadata, dispatch) => { KEEP_CONTENT: false, ALLOW_DATA_ATTR: false }; - const rawDescription = marked(metadata.description); - const cleanDescription = sanitizer(rawDescription, sanitizerConfig); + + + let cleanDescription; + try + { + const rawDescription = marked(metadata.description); + cleanDescription = sanitizer(rawDescription, sanitizerConfig); + } catch (error) { + console.error(`Error parsing footer description: ${error}`) + cleanDescription = (

Something went wrong.

); + } + return (
Date: Sat, 11 Apr 2020 22:55:03 -0500 Subject: [PATCH 2/4] Modified error message --- src/components/framework/footer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/framework/footer.js b/src/components/framework/footer.js index efbe55cd7..163c27aa3 100644 --- a/src/components/framework/footer.js +++ b/src/components/framework/footer.js @@ -170,8 +170,8 @@ export const getAcknowledgments = (metadata, dispatch) => { const rawDescription = marked(metadata.description); cleanDescription = sanitizer(rawDescription, sanitizerConfig); } catch (error) { - console.error(`Error parsing footer description: ${error}`) - cleanDescription = (

Something went wrong.

); + console.error(`Error parsing footer description: ${error}`); + cleanDescription = (

There was an error parsing the footer description.

); } return ( From b1cb949f8a82db42ecb3fc30232bd2ae28d4c95d Mon Sep 17 00:00:00 2001 From: james hadfield Date: Wed, 15 Apr 2020 15:57:21 +1200 Subject: [PATCH 3/4] Fix rendering of error message `cleanDescription` is an HTML string to be rendered, not a react element. --- src/components/framework/footer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/framework/footer.js b/src/components/framework/footer.js index 163c27aa3..049e4a721 100644 --- a/src/components/framework/footer.js +++ b/src/components/framework/footer.js @@ -171,7 +171,7 @@ export const getAcknowledgments = (metadata, dispatch) => { cleanDescription = sanitizer(rawDescription, sanitizerConfig); } catch (error) { console.error(`Error parsing footer description: ${error}`); - cleanDescription = (

There was an error parsing the footer description.

); + cleanDescription = '

There was an error parsing the footer description.

'; } return ( From a36d3c1977be0c763fd544a685d0dd1b2e40d775 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Wed, 15 Apr 2020 15:57:47 +1200 Subject: [PATCH 4/4] fix linting errors --- src/components/framework/footer.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/framework/footer.js b/src/components/framework/footer.js index 049e4a721..430ac2fba 100644 --- a/src/components/framework/footer.js +++ b/src/components/framework/footer.js @@ -162,11 +162,9 @@ export const getAcknowledgments = (metadata, dispatch) => { KEEP_CONTENT: false, ALLOW_DATA_ATTR: false }; - - + let cleanDescription; - try - { + try { const rawDescription = marked(metadata.description); cleanDescription = sanitizer(rawDescription, sanitizerConfig); } catch (error) {