How to disable the execution of JavaScript, when it is output to the page when it is contained in the data

We use jquery-datatable to render a piece of material obtained by table, and one of the columns will encounter something like:

8080::HTTP/1.1 200 OK | < script > window.location.href = " http://example:8080/a.asp";</script>

when rendering, the browser executes the script and the page jumps.
what can I do to prevent running JavaScript, to solve security implications?

Mar.13,2021

Common security issues, the technical term XSS , you can search for related articles.

The simple solution here is to escape & < > and other special characters by html escape.

& -> &
< -> <
> -> >

how to disable execution when outputting to a page

try to escape a string or fail direct validation when enters . A data is added only once, but you don't know how many times to visit it.


");
    s = s.replace(/ /g, "");
    s = s.replace(/\'/g, "'");
    s = s.replace(/\"/g, """);
    s = s.replace(/\n/g, "<br>");
    return s;
}
xssText('<script>window.location.href = "http://example:8080/a.asp";</script>')
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34990-2bf1c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34990-2bf1c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?