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:
1 parent
0b26aa2029
commit
6a23996c38
2 files changed
+27
-2
No files matched your search
+2
-2
@@ -109,7 +109,7 @@ func showInfo(str string) {
|
||||
|
||||
printLogOnScreen(logMsg, "info")
|
||||
|
||||
logAppend(strings.Replace(logMsg, " ", " ", -1))
|
||||
logAppend(logMsg)
|
||||
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func showDebug(str string, level int) {
|
||||
|
||||
printLogOnScreen(logMsg, "debug")
|
||||
|
||||
logAppend(strings.Replace(logMsg, " ", " ", -1))
|
||||
logAppend(logMsg)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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, " ") {
|
||||
t.Errorf("log line contains an HTML entity: %q", line)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user