Skip to content

Commit

Permalink
check for html letters
Browse files Browse the repository at this point in the history
  • Loading branch information
FebbanHD123 committed Mar 15, 2022
1 parent 76d20db commit 8f88d9a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions API.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
async function load(logID) {
const response = await fetch("http://localhost:8082/chatlog/v1/get/" + logID + "/")
const response = await fetch("http://45.142.114.107:8082/chatlog/v1/get/" + logID + "/")

if(response.ok) {
const json = await response.json();
Expand All @@ -19,8 +19,8 @@ async function load(logID) {
var row = `<tr>
<td id="head"><img src="https://mc-heads.net/avatar/${uuid}/35.png"></td>
<td id="time">${dateObject.toLocaleString("de-DE")}</td>
<td id="name">${displayName}</td>
<td id="message">${message}</td>
<td id="name">${escapeHtml(displayName)}</td>
<td id="message">${escapeHtml(message)}</td>
</tr>`
table.innerHTML += row

Expand All @@ -32,6 +32,12 @@ async function load(logID) {
}
}

function escapeHtml(raw) {
return raw.replace(/[&<>"']/g, function onReplace(match) {
return '&#' + match.charCodeAt(0) + ';';
});
}

function setState(code) {
document.getElementById('state').innerHTML = code;
}
Expand Down

0 comments on commit 8f88d9a

Please sign in to comment.