From 1df6edd44744904c5aec9d08db7d6aa59b57c8e6 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 27 Dec 2019 13:21:15 -0500 Subject: [PATCH] LP#1857710: fix Angular client whitescreen on Firefox Work done for LP#1830391 added an instance of a Javascript regexp replace using the dotAll ("/s") flag, but as of the moment Firefox treats that flag as a fatal syntax error, breaking the Angular staff client. To test ------- [1] Attempt to log in the Angular staff client with Firefox. Note that you get a whitescreen with the following in the browser console: SyntaxError: invalid regular expression flag s [2] Apply the patch and repeat step 1. This time, the Angular staff client should work normally. [3] Verify that the Angular unit tests pass. Signed-off-by: Galen Charlton Signed-off-by: Jason Boyer --- .../src/app/share/util/htmltotxt.service.spec.ts | 15 +++++++++++++++ .../eg2/src/app/share/util/htmltotxt.service.ts | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.spec.ts diff --git a/Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.spec.ts b/Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.spec.ts new file mode 100644 index 0000000000..1d2345c96e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.spec.ts @@ -0,0 +1,15 @@ +import {HtmlToTxtService} from './htmltotxt.service'; + +let h2txt: HtmlToTxtService; + +beforeEach(() => { + h2txt = new HtmlToTxtService(); +}); + +describe('HtmlToTxtService', () => { + it('htmlToTxt cleans multiline comments', () => { + // this is a regression test for LP#1857710 on Firefox + const str = '

A print template

body of template
'; + expect(h2txt.htmlToTxt(str)).toEqual('A print template body of template'); + }); +}); diff --git a/Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.ts b/Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.ts index e265b3d2fa..25b602c3ce 100644 --- a/Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.ts +++ b/Open-ILS/src/eg2/src/app/share/util/htmltotxt.service.ts @@ -38,7 +38,11 @@ export class HtmlToTxtService { } // First remove multi-line comments. - html = html.replace(//gs, ''); + // NOTE: the regexp was originally //gs + // but as of 2019-12-27 Firefox does not support + // the ES2018 regexp dotAll flag and Angular/tsc doesn't + // seem set up to transpile it + html = html.replace(//g, ''); const lines = html.split(/\n/); const newLines = []; -- 2.43.2