Skip to content

Commit e5880b6

Browse files
AdSkipper1337djc
authored andcommitted
removed check for null characters in literal function with test
1 parent 3e0d47a commit e5880b6

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

imap-proto/src/parser/core.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,9 @@ pub fn literal(input: &[u8]) -> IResult<&[u8], &[u8]> {
9898

9999
let (remaining, data) = take(count)(remaining)?;
100100

101-
if !data.iter().all(|byte| is_char8(*byte)) {
102-
// FIXME: what ErrorKind should this have?
103-
return Err(nom::Err::Error(nom::error::Error::new(
104-
remaining,
105-
nom::error::ErrorKind::Verify,
106-
)));
107-
}
108-
109101
Ok((remaining, data))
110102
}
111103

112-
/// CHAR8 = %x01-ff ; any OCTET except NUL, %x00
113-
pub fn is_char8(i: u8) -> bool {
114-
i != 0
115-
}
116-
117104
// ----- astring ----- atom (roughly) or string
118105

119106
// astring = 1*ASTRING-CHAR / string
@@ -285,6 +272,16 @@ mod tests {
285272
}
286273
}
287274

275+
#[test]
276+
fn test_string_literal_containing_null() {
277+
match string(b"{5}\r\nX\0Y\0Z") {
278+
Ok((_, value)) => {
279+
assert_eq!(value, b"X\0Y\0Z");
280+
}
281+
rsp => panic!("unexpected response {rsp:?}"),
282+
}
283+
}
284+
288285
#[test]
289286
fn test_astring() {
290287
match astring(b"text ") {

0 commit comments

Comments
 (0)