'How to decode html escaped attributes while render <a> tag in jquery datatable?

How to decode html escaped attributes while render tag in jquery datatable?

I'm using jquery dataTable. While rendering the to table column it replace the "&" to "&amp;" and I want to remove them.

{
    data: 'name',
    name: 'name',
    render: function (cell, _, row) {
        let link = document.createElement('a');
        link.href = row.id.href;
        link.textContent = cell;
        return link.outerHTML;
    }
},

If I use like the following, does this introduce an risk of XSS?

'<a href="'+row.id.href+'">'+cell+'</a>';

Is there any other way to render tag in dataTable?

Thanks in advance..



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source