html sanitize

Added a function to sanitize the html
This is for browser side only.
This commit is contained in:
Emre Saglam 2020-03-24 08:37:56 -07:00
parent a6ac902bf4
commit 86e1ba871f

View File

@ -147,6 +147,14 @@
</body>
<script>
function sanitizeHTMLEntities (str) {
if(str && typeof str === 'string') {
str = str.replace(/</g,"&lt;");
str = str.replace(/>/g,"&gt;");
}
return str;
}
function httpGet(theUrl) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false); // false for synchronous request
@ -169,7 +177,8 @@
lastRequest.open("GET", theUrl, true);
lastRequest.onload = function (e) {
if (lastRequest.readyState === 4 && lastRequest.status === 200) {
let httpResults = JSON.parse(lastRequest.responseText);
let sanitizedResponseText = lastRequest.responseText;
let httpResults = JSON.parse(sanitizedResponseText);
results.innerHTML = '';
let processingTimeMs = httpResults.processingTimeMs;