From 8a40e6586a76c2294a17e90e2b1d44dccd10db0d Mon Sep 17 00:00:00 2001 From: c Date: Mon, 10 Nov 2025 13:12:54 +0100 Subject: [PATCH 1/2] test: no terminating newlines should not be an obstacle for parsing --- resources/unstructured.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/unstructured.json b/resources/unstructured.json index d68ea06b..b5761afc 100644 --- a/resources/unstructured.json +++ b/resources/unstructured.json @@ -118,5 +118,9 @@ { "header": "Les Communs - =?utf-8?Q?R=C3=A9capitulatif?= de la\r\n =?utf-8?Q?r=C3=A9servation?= 13510164434879\r\n", "expected": "Les Communs - Récapitulatif de la réservation 13510164434879" + }, + { + "header": "=?utf-8?Q?Peri=C3=B1an?= missing text", + "expected": "Periñan missing text" } ] \ No newline at end of file From d368d4eafa6315be85f6f475870e2343d6a41e46 Mon Sep 17 00:00:00 2001 From: c Date: Mon, 10 Nov 2025 13:13:48 +0100 Subject: [PATCH 2/2] fix: unstructured headers should salvage as much text as feasible --- src/parsers/fields/unstructured.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parsers/fields/unstructured.rs b/src/parsers/fields/unstructured.rs index b92367df..0cd1e8f5 100644 --- a/src/parsers/fields/unstructured.rs +++ b/src/parsers/fields/unstructured.rs @@ -84,7 +84,13 @@ impl<'x> MessageStream<'x> { parser.token_end = self.offset(); } - HeaderValue::Empty + parser.add_token(self); + + match parser.tokens.len() { + 1 => HeaderValue::Text(parser.tokens.pop().unwrap()), + 0 => HeaderValue::Empty, + _ => HeaderValue::Text(parser.tokens.concat().into()), + } } }