From 59a5077713482a3769b09788573535a6b5fce0d3 Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Mon, 24 Apr 2023 13:00:14 -0400 Subject: [PATCH] Add RFC 2047 encoding support for tags --- server/server.go | 3 +++ server/server_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/server/server.go b/server/server.go index 5c4f2a9e..d07a6159 100644 --- a/server/server.go +++ b/server/server.go @@ -892,6 +892,9 @@ func (s *Server) parsePublishParams(r *http.Request, m *message) (cache bool, fi return false, false, "", false, errHTTPBadRequestPriorityInvalid } m.Tags = readCommaSeparatedParam(r, "x-tags", "tags", "tag", "ta") + for i, t := range m.Tags { + m.Tags[i] = maybeDecodeHeader(t) + } delayStr := readParam(r, "x-delay", "delay", "x-at", "at", "x-in", "in") if delayStr != "" { if !cache { diff --git a/server/server_test.go b/server/server_test.go index 0dc34632..fa41ac52 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -2474,12 +2474,15 @@ func TestServer_PublishWithUTF8MimeHeader(t *testing.T) { "X-Filename": "some attachment.txt", "X-Message": "=?UTF-8?B?8J+HqfCfh6o=?=", "X-Title": "=?UTF-8?B?bnRmeSDlvojmo5I=?=, no really I mean it! =?UTF-8?Q?This is q=C3=BC=C3=B6ted-print=C3=A4ble.?=", + "X-Tags": "=?UTF-8?B?8J+HqfCfh6o=?=, =?UTF-8?B?bnRmeSDlvojmo5I=?=", }) require.Equal(t, 200, response.Code) m := toMessage(t, response.Body.String()) require.Equal(t, "🇩🇪", m.Message) require.Equal(t, "ntfy 很棒, no really I mean it! This is qüöted-printäble.", m.Title) require.Equal(t, "some attachment.txt", m.Attachment.Name) + require.Equal(t, "🇩🇪", m.Tags[0]) + require.Equal(t, "ntfy 很棒", m.Tags[1]) } func newTestConfig(t *testing.T) *Config {