Fix log view showing   entities
continuous-integration/drone/push Build is passing

The server padded log lines by replacing every space with  , which
only worked while the UI inserted log lines as HTML. Since the log is now
rendered as text (inside <pre>, so whitespace is preserved anyway), the
entities showed up literally. Store plain spaces instead.

Test: TestLogLinesContainNoHTMLEntities.
This commit is contained in:
nathan committed 2026-10-02 09:54:34 +10:00
1 parent 0b26aa2029
commit 6a23996c38
2 files changed
+27 -2

No files matched your search

+2 -2
View File
@@ -109,7 +109,7 @@ func showInfo(str string) {
printLogOnScreen(logMsg, "info") printLogOnScreen(logMsg, "info")
logAppend(strings.Replace(logMsg, " ", "&nbsp;", -1)) logAppend(logMsg)
} }
@@ -137,7 +137,7 @@ func showDebug(str string, level int) {
printLogOnScreen(logMsg, "debug") printLogOnScreen(logMsg, "debug")
logAppend(strings.Replace(logMsg, " ", "&nbsp;", -1)) logAppend(logMsg)
} }
+25
View File
@@ -106,3 +106,28 @@ func TestShowHighlightWithoutColon(t *testing.T) {
} }
} }
} }
// The web UI renders log lines as text inside <pre>, so the server must store
// plain spaces, not HTML entities.
func TestLogLinesContainNoHTMLEntities(t *testing.T) {
var oldLimit = Settings.LogEntriesRAM
Settings.LogEntriesRAM = 500
t.Cleanup(func() { Settings.LogEntriesRAM = oldLimit })
resetWebScreenLog()
showInfo("Version:2.2.0 Build: 0201")
showDebug("Buffer Status:some debug text", 0)
snap := webScreenLogSnapshot()
if len(snap.Log) == 0 {
t.Fatal("no log lines recorded")
}
if !strings.Contains(snap.Log[0], "Version: 2.2.0 Build: 0201") {
t.Errorf("padding should be plain spaces, got %q", snap.Log[0])
}
for _, line := range snap.Log {
if strings.Contains(line, "&nbsp;") {
t.Errorf("log line contains an HTML entity: %q", line)
}
}
}