I'm trying to encode the string:

using
Code:
Ext.util.Format.htmlEncode("localhost.loca<img src=x onerror=alert(1)>ldomain")
I also tried
Code:
Ext.String.htmlEncode
, but this renders undefined for me, not sure how to fadd encoding to prevent js alerting on every error.

this is my code:

Code:
 getAssetName: function() {
                        if (someCondition) {
                            return '<a href="#">' + Ext.util.Format.htmlEncode("localhost.loca<img src=x onerror=alert(1)>ldomain") + '</a>';
                        } else {
                            return '<span>' + Ext.util.Format.htmlEncode("localhost.loca<img src=x onerror=alert(1)>ldomain") + '</span>';
                        }
                    },