From b9cd89128dd207045b84461b01aaf663b03e4a5c Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 20 Mar 2021 22:31:56 -0500 Subject: [PATCH] fix: try catch toHtml --- lib/script-view.js | 8 +++++++- spec/fixtures/issue_2358.py | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/issue_2358.py diff --git a/lib/script-view.js b/lib/script-view.js index 348d5026..d54de82a 100644 --- a/lib/script-view.js +++ b/lib/script-view.js @@ -173,7 +173,13 @@ export default class ScriptView extends MessagePanelView { line = _.escape(line); } - line = this.ansiFilter.toHtml(line); + try { + line = this.ansiFilter.toHtml(line); + } catch (e) { + // TODO why this happens https://github.com/atom-community/atom-script/issues/2358 + console.error(e); + } + line = linkPaths(line); const { clientHeight, scrollTop, scrollHeight } = this.body[0]; diff --git a/spec/fixtures/issue_2358.py b/spec/fixtures/issue_2358.py new file mode 100644 index 00000000..940b8ca8 --- /dev/null +++ b/spec/fixtures/issue_2358.py @@ -0,0 +1,9 @@ +# See the console after running this + +import requests + +head = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/65.0.3325.181 Chrome/65.0.3325.181 Safari/537.36'} + +r = requests.get('https://www.oxfordlearnersdictionaries.com/us/wordlists/oxford3000-5000', headers=head) + +print(r.text)