MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestExtractThreadInfoDecodesEncodedSubject

Function TestExtractThreadInfoDecodesEncodedSubject

internal/relay/server_test.go:253–288  ·  view source on GitHub ↗

TestExtractThreadInfoDecodesEncodedSubject covers RFC 2047 encoded-word subjects like the ones SES emits for unicode characters. Storing the wire form leaked `=?utf-8?q?...?=` into list summaries, dashboards, and the CLI inbox — every consumer that didn't independently re-parse raw_message.

(t *testing.T)

Source from the content-addressed store, hash-verified

251// form leaked `=?utf-8?q?...?=` into list summaries, dashboards, and the CLI
252// inbox — every consumer that didn't independently re-parse raw_message.
253func TestExtractThreadInfoDecodesEncodedSubject(t *testing.T) {
254 cases := []struct {
255 name string
256 raw string
257 want string
258 }{
259 {
260 name: "Q-encoded em dash",
261 raw: "Message-Id: <x@send.e2a.dev>\r\nSubject: =?utf-8?q?e2a_MCP_e2e_=E2=80=94_HITL_approve_path?=\r\nFrom: a@b.com\r\nTo: c@d.com\r\n\r\nHi\r\n",
262 want: "e2a MCP e2e — HITL approve path",
263 },
264 {
265 name: "B-encoded utf-8",
266 raw: "Message-Id: <x@send.e2a.dev>\r\nSubject: =?utf-8?B?Y2Fmw6k=?=\r\nFrom: a@b.com\r\nTo: c@d.com\r\n\r\nHi\r\n",
267 want: "café",
268 },
269 {
270 name: "plain ASCII passes through untouched",
271 raw: "Message-Id: <x@send.e2a.dev>\r\nSubject: Plain ASCII\r\nFrom: a@b.com\r\nTo: c@d.com\r\n\r\nHi\r\n",
272 want: "Plain ASCII",
273 },
274 {
275 name: "malformed encoded-word falls back to raw",
276 raw: "Message-Id: <x@send.e2a.dev>\r\nSubject: =?utf-8?q?broken\r\nFrom: a@b.com\r\nTo: c@d.com\r\n\r\nHi\r\n",
277 want: "=?utf-8?q?broken",
278 },
279 }
280 for _, tc := range cases {
281 t.Run(tc.name, func(t *testing.T) {
282 got := extractThreadInfo([]byte(tc.raw)).Subject
283 if got != tc.want {
284 t.Errorf("Subject = %q, want %q", got, tc.want)
285 }
286 })
287 }
288}
289
290func TestSessionResetClearsThreadInfo(t *testing.T) {
291 s := &session{

Callers

nothing calls this directly

Calls 2

extractThreadInfoFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected