Skip to content

Commit

Permalink
luci-base: form.js: decode HTML entities in AbstractElement.stripTags()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mikma authored and systemcrash committed Sep 18, 2024
1 parent dfb8670 commit 470bb2b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions modules/luci-base/htdocs/luci-static/resources/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>');
Expand Down

0 comments on commit 470bb2b

Please sign in to comment.