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 <mikma@users.sourceforge.net>
This commit is contained in:
Mikael Magnusson 2024-08-20 22:17:36 +02:00 committed by Paul Donald
parent dfb86709c6
commit 470bb2b854
1 changed files with 5 additions and 3 deletions

View File

@ -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('<div>' + s + '</div>');