add compatibility for \r\r\n

This commit is contained in:
Quentin 2023-07-25 18:27:19 +02:00
parent 987024430b
commit b64c032bff
Signed by: quentin
GPG key ID: E9602264D639FF68
2 changed files with 6 additions and 1 deletions

View file

@ -136,6 +136,11 @@ pub const TILDE: u8 = 0x7E; // ~
// GROUP OF CHARACTERS
// -- CRLF
pub const CRLF: &[u8] = &[CR, LF];
// -- CRCRLF
// Sometimes portable libraries replace transparently
// the "\n" with "\r\n" on Windows. When developpers
// explicitly write "\r\n", the library generates "\r\r\n".
pub const CRCRLF: &[u8] = &[CR, CR, LF];
// -- WHITESPACE
pub const WS: &[u8] = &[HT, SP];

View file

@ -22,7 +22,7 @@ use nom::{
/// \r or \n is allowed nowhere else, so we also add this support.
pub fn obs_crlf(input: &[u8]) -> IResult<&[u8], &[u8]> {
alt((tag(ascii::CRLF), tag(&[ascii::CR]), tag(&[ascii::LF])))(input)
alt((tag(ascii::CRLF), tag(ascii::CRCRLF), tag(&[ascii::CR]), tag(&[ascii::LF])))(input)
}
/// ```abnf