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 <gmc@equinoxinitiative.org>
Signed-off-by: Jason Boyer <JBoyer@eoli.info>
--- /dev/null
+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 = '<h1>A print template</h1> <!-- I am a comment\nwith an embedded newline --> <div>body of template</div>';
+ expect(h2txt.htmlToTxt(str)).toEqual('A print template body of template');
+ });
+});
}
// 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 = [];