Skip to content

Commit d9a5bc8

Browse files
authored
Fix potential issue in toHTML (#95)
Chat message may have a `translate` field, but with no `with` field. Fixes toHTML code trying to iterate over possibly undefined field
1 parent 1f19bcc commit d9a5bc8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,10 @@ function loader (registryOrVersion) {
411411
str += escapeHtml(this.text)
412412
} else if (this.translate) {
413413
const params = []
414-
for (const param of this.with) {
415-
params.push(param.toHTML(lang, styles, allowedFormats))
414+
if (this.with) {
415+
for (const param of this.with) {
416+
params.push(param.toHTML(lang, styles, allowedFormats))
417+
}
416418
}
417419
const format = lang[this.translate] ?? this.translate
418420
str += vsprintf(escapeHtml(format), params)

0 commit comments

Comments
 (0)