Skip to content

Commit 87ed3f6

Browse files
Livecode fix (un)escapeHtml functions for empty strings
1 parent a6bf257 commit 87ed3f6

File tree

1 file changed

+6
-0
lines changed
  • bases/rsptx/interactives/runestone/activecode/js

1 file changed

+6
-0
lines changed

bases/rsptx/interactives/runestone/activecode/js/livecode.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,9 @@ export default class LiveCode extends ActiveCode {
958958
return classes;
959959
}
960960
}
961+
962+
// Warning - returns undefined if safe is an empty string
963+
// existing usages in constructor appear to rely on that behavior
961964
function unescapeHtml(safe) {
962965
if (safe) {
963966
return safe
@@ -968,6 +971,8 @@ function unescapeHtml(safe) {
968971
.replace(/'/g, "'");
969972
}
970973
}
974+
975+
// Designed to produce HTML from a string, so always return a string
971976
function escapeHtml(str) {
972977
if (str) {
973978
return str
@@ -977,4 +982,5 @@ function escapeHtml(str) {
977982
.replace(/'/g, ''')
978983
.replace(/"/g, '"');
979984
}
985+
return '';
980986
}

0 commit comments

Comments
 (0)