Skip to content

Commit 28db94a

Browse files
committed
fix-no-newline-parse
Dearest Reviewer, Issue stalwartlabs#90 brought up the issue that if there was no newline. the user provided an easy reproduction case. I was able to track it down to the parse raw function. The issue is that the loop hits the end of the string and returns Empty. However, if there is a start offset then some characters were found. This code just checks the offset after the loop. If this is not the correct behavior please close. Thanks for your time Becker
1 parent b0ba8db commit 28db94a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/parsers/fields/raw.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ impl<'x> MessageStream<'x> {
3737
token_end = self.offset();
3838
}
3939

40-
HeaderValue::Empty
40+
if token_start > 0 {
41+
HeaderValue::Text(String::from_utf8_lossy(
42+
self.bytes(token_start - 1..token_end),
43+
))
44+
} else {
45+
HeaderValue::Empty
46+
}
4147
}
4248

4349
pub fn parse_and_ignore(&mut self) {
@@ -70,6 +76,7 @@ mod tests {
7076
"for <mary@example.net>; 21 Nov 1997 10:05:43 -0600"
7177
),
7278
),
79+
("Re: Saying Hello", "Re: Saying Hello"), // No newline test
7380
];
7481

7582
for (input, expected) in inputs {

0 commit comments

Comments
 (0)