Skip to content

Commit 19067f6

Browse files
authored
Merge pull request #16 from uthmanrahimi/master
Added a function to replace reserved HTML characters.
2 parents 1385c01 + b978950 commit 19067f6

File tree

1 file changed

+5
-1
lines changed
  • src/Serilog.Ui.Web/wwwroot/dist

1 file changed

+5
-1
lines changed

src/Serilog.Ui.Web/wwwroot/dist/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const fetchData = () => {
159159
<td class="text-center"><span class="log-level text-white ${levelClass(log.level)}">${log.level}</span></td>
160160
<td class="text-center">${formatDate(log.timestamp)}</td>
161161
<td class="log-message">
162-
<span class="overflow-auto"><truncate length="100">${truncateString(log.message, 100)}</truncate></span>
162+
<span class="overflow-auto"><truncate length="100">${truncateString(cleanHtmlTags(log.message), 100)}</truncate></span>
163163
</td>
164164
<td class="text-center">
165165
${exception}
@@ -289,4 +289,8 @@ const initTokenUi = () => {
289289
$("#tokenContainer").text("*********");
290290
$("#saveJwt").text("Clear").data("saved", "true");
291291
$("#jwtModalBtn").find("i").removeClass("fa-unlock").addClass("fa-lock");
292+
}
293+
294+
const cleanHtmlTags= (str)=> {
295+
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
292296
}

0 commit comments

Comments
 (0)