mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-06-16 03:49:08 -04:00
escapeStringMap mutated its input map. The recipient loop in eventsNotifier.render reuses that map across iterations, so each recipient past the first got values with one extra HTML escape layer. Return a new map instead. Fixes #2804 Signed-off-by: Michael Stingl <mail@michaelstingl.com>
26 lines
805 B
Go
26 lines
805 B
Go
package email
|
|
|
|
import "testing"
|
|
|
|
// Regression for #2804: escapeStringMap used to mutate its input map, and the
|
|
// recipient render loop reuses that map across iterations.
|
|
func TestEscapeStringMapDoesNotMutateInput(t *testing.T) {
|
|
const raw = "Test & Demo"
|
|
input := map[string]string{"SpaceName": raw}
|
|
|
|
first := escapeStringMap(input)
|
|
second := escapeStringMap(input)
|
|
|
|
if got, want := first["SpaceName"], "Test & Demo"; got != want {
|
|
t.Errorf("first call: got %q, want %q", got, want)
|
|
}
|
|
if first["SpaceName"] != second["SpaceName"] {
|
|
t.Errorf("escapeStringMap not idempotent on shared input: first=%q second=%q",
|
|
first["SpaceName"], second["SpaceName"])
|
|
}
|
|
if input["SpaceName"] != raw {
|
|
t.Errorf("escapeStringMap mutated its input: got %q, want %q",
|
|
input["SpaceName"], raw)
|
|
}
|
|
}
|