diff --git a/internal/shared/parseutils.go b/internal/shared/parseutils.go index 7c79b745..d3e635a4 100644 --- a/internal/shared/parseutils.go +++ b/internal/shared/parseutils.go @@ -142,16 +142,16 @@ func DecodeEntities(str string) (string, error) { name := string(data[1:end]) var c byte - switch name { - case "lt": + switch { + case strings.EqualFold("lt", name): c = '<' - case "gt": + case strings.EqualFold("gt", name): c = '>' - case "quot": + case strings.EqualFold("quot", name): c = '"' - case "apos": + case strings.EqualFold("apos", name): c = '\'' - case "amp": + case strings.EqualFold("amp", name): c = '&' default: return "", fmt.Errorf("unknown predefined "+ diff --git a/internal/shared/parseutils_test.go b/internal/shared/parseutils_test.go index c80842dc..de4396e5 100644 --- a/internal/shared/parseutils_test.go +++ b/internal/shared/parseutils_test.go @@ -19,6 +19,11 @@ func TestDecodeEntities(t *testing.T) { {"<foo>", ""}, {"a "b" 'c'", "a \"b\" 'c'"}, {"foo && bar", "foo && bar"}, + {"&", "&"}, + {"<", "<"}, + {">", ">"}, + {"&APOS;", "'"}, + {""", "\""}, {""foo"", "\"foo\""}, {"abc", "abc"},