' + simplePhr + ' = ' + curCipher.sumArr.reduce(getSum) + ' ' // add all values in array
+ o += '
' + escHtml(simplePhr) + ' = ' + curCipher.sumArr.reduce(getSum) + ' ' // add all values in array
o += '(' + curCipher.cipherName + gemCalcModeLabel(curCipher) + ')
'
$('#BreakTableContainer').prepend(o) // insert in the beginning of the table
}
diff --git a/calc/calc.js b/calc/calc.js
index 3b6f5cf..a6d2092 100644
--- a/calc/calc.js
+++ b/calc/calc.js
@@ -1763,6 +1763,19 @@ function updateEnabledCipherCount() {
}
}
+// Entity-escape user-supplied text before it enters an innerHTML string — for the HTML body AND
+// for values inside double-quoted attributes (escapes & < > " '). Store phrases RAW; escape only
+// here at render. Added 2026-09-13 (the calc had no escaping; phrases reached the DOM raw). Keep
+// every user-text sink routed through this.
+function escHtml(s) {
+ return String(s)
+ .replace(/&/g, "&")
+ .replace(//g, ">")
+ .replace(/"/g, """)
+ .replace(/'/g, "'");
+}
+
function sVal() {
return document.getElementById("phraseBox").value.trim(); // get value, remove spaces from both sides
}
@@ -2248,11 +2261,11 @@ function updateHistoryTable(hltBoolArr) {
// comment first, phrase without comment and leading/trailing spaces
dispPhrase =
'' +
- tmpComment +
+ escHtml(tmpComment) +
"" +
- sHistory[x].replace(/\[.+\]/g, "").trim();
+ escHtml(sHistory[x].replace(/\[.+\]/g, "").trim());
} else {
- dispPhrase = sHistory[x];
+ dispPhrase = escHtml(sHistory[x]);
}
ms += '
' + dispPhrase + "
"; // hP - history phrase, add data index
var col = ""; // value color
diff --git a/calc/database.js b/calc/database.js
index 8c6d058..ae626f6 100644
--- a/calc/database.js
+++ b/calc/database.js
@@ -249,7 +249,7 @@ function updateDatabaseQueryTable(stPos = 0, dItems, scrollBarEvent = false) { /
ms += '
_
'
ms += ''
ms += '' // slider/scrollbar
- ms += '' // search bar
+ ms += '' // search bar
ms += '
' // phrase at index 1 (title + body both escaped)
valPos = 2 // reset position for new phrase
for (y = 0; y < gemArrCiph.length; y++) { // gemArrCiph contains indices of ciphers used for query
diff --git a/index.html b/index.html
index ef2fb2a..8c15168 100644
--- a/index.html
+++ b/index.html
@@ -16,7 +16,7 @@
-
+
@@ -146,7 +146,7 @@
-
+
@@ -154,7 +154,7 @@
-
+