From 836fe77c372eaa10bf6273b0efef54f6bcd709bb Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 9 Mar 2016 16:53:02 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20bug=20with=20=E2=80=98ghost=E2=80=99=20li?= =?UTF-8?q?nks=20in=20template=20textbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a bug with the code that highlights placeholders. It was taking the value of the textbox and copying it straight into the HTML of the layer that contains the blue lozenges. This meant that any HTML that the user typed into the textbox was rendered by the browser. This commit fixes the bug by: 1. taking the contents of the textbox 2. copying it to the _text_ (not inner HTML) of a temporary `
` 3. taking the inner HTML of that `
` (whose text has been encoded with HTML entities in step 2., eg `>` becomes `>`) 4. using that for the HTML content of the layer with the blue lozenges --- app/assets/javascripts/highlightTags.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/highlightTags.js b/app/assets/javascripts/highlightTags.js index f0f46fcd9..a1ecf2f37 100644 --- a/app/assets/javascripts/highlightTags.js +++ b/app/assets/javascripts/highlightTags.js @@ -33,7 +33,7 @@ }; this.update = () => this.$backgroundMaskForeground.html( - this.$textbox.val().replace( + $('
').text(this.$textbox.val()).html().replace( tagPattern, match => `${match}` ) );