From 470bb2b8540e5b4949c66b04e5f583c5c36a5a7b Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 20 Aug 2024 22:17:36 +0200 Subject: luci-base: form.js: decode HTML entities in AbstractElement.stripTags() This commit fixes a problem with HTML entities which were visible in their encoded form in the mobile view. This happened for example when displaying a GridSection with a Value option containing " " in the title. Without this change only HTML entities in titles that also contains tags are decoded before they are stored in data-title attributes. Signed-off-by: Mikael Magnusson --- modules/luci-base/htdocs/luci-static/resources/form.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/luci-base/htdocs/luci-static/resources') diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 3834bceb01..624bc2c2f8 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -275,16 +275,18 @@ var CBIAbstractElement = baseclass.extend(/** @lends LuCI.form.AbstractElement.p }, /** - * Strip any HTML tags from the given input string. + * Strip any HTML tags from the given input string, and decode + * HTML entities. * * @param {string} s * The input string to clean. * * @returns {string} - * The cleaned input string with HTML tags removed. + * The cleaned input string with HTML tags removed, and HTML + * entities decoded. */ stripTags: function(s) { - if (typeof(s) == 'string' && !s.match(/[<>]/)) + if (typeof(s) == 'string' && !s.match(/[<>\&]/)) return s; var x = dom.elem(s) ? s : dom.parse('
' + s + '
'); -- cgit v1.2.3