Skip to content

Commit a9eee5d

Browse files
jasonishvictorjulien
authored andcommitted
rust/htp: convert to nom 8
Ticket: OISF#8090
1 parent ef9cd7b commit a9eee5d

12 files changed

Lines changed: 243 additions & 216 deletions

rust/Cargo.lock.in

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/htp/Cargo.toml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ crate-type = ["staticlib", "rlib", "cdylib"]
2424
base64 = "0.22.1"
2525
bstr = "1.12.0"
2626
libc = "0.2"
27-
nom = "7.1.3"
27+
nom = "8.0.0"
2828
lzma-rs = { version = "0.2.0", features = ["stream"] }
2929
flate2 = { version = "~1.0.35", features = ["zlib-default"], default-features = false }
3030
brotli = "~8.0.1"

rust/htp/src/decompressors.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use brotli;
2+
use nom::Parser as _;
23
use std::{
34
io::{Cursor, Write},
45
time::Instant,
@@ -455,10 +456,9 @@ impl GzipBufWriter {
455456
fn parse_start(data: &[u8]) -> nom::IResult<&[u8], u8> {
456457
use nom::bytes::streaming::tag;
457458
use nom::number::streaming::{le_i32, le_u8};
458-
use nom::sequence::tuple;
459459

460460
let (rest, (_, flags, _mtime, _xfl, _operating_system)) =
461-
tuple((tag(b"\x1f\x8b\x08"), le_u8, le_i32, le_u8, le_u8))(data)?;
461+
(tag(&b"\x1f\x8b\x08"[..]), le_u8, le_i32, le_u8, le_u8).parse(data)?;
462462
Ok((rest, flags))
463463
}
464464
}
@@ -467,7 +467,6 @@ impl Write for GzipBufWriter {
467467
fn write(&mut self, data: &[u8]) -> std::io::Result<usize> {
468468
use nom::bytes::streaming::{tag, take_until};
469469
use nom::number::streaming::le_u16;
470-
use nom::sequence::tuple;
471470

472471
const FHCRC: u8 = 1 << 1;
473472
const FEXTRA: u8 = 1 << 2;
@@ -534,10 +533,11 @@ impl Write for GzipBufWriter {
534533
}
535534
GzState::Filename => {
536535
if self.flags & FNAME != 0 {
537-
match tuple((
536+
match (
538537
take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>(b"\0" as &[u8]),
539-
tag(b"\0"),
540-
))(parse)
538+
tag(&b"\0"[..]),
539+
)
540+
.parse(parse)
541541
{
542542
Ok((rest, _)) => {
543543
parse = rest;
@@ -557,10 +557,11 @@ impl Write for GzipBufWriter {
557557
}
558558
GzState::Comment => {
559559
if self.flags & FCOMMENT != 0 {
560-
match tuple((
560+
match (
561561
take_until::<&[u8], &[u8], nom::error::Error<&[u8]>>(b"\0" as &[u8]),
562-
tag(b"\0"),
563-
))(parse)
562+
tag(&b"\0"[..]),
563+
)
564+
.parse(parse)
564565
{
565566
Ok((rest, _)) => {
566567
parse = rest;

0 commit comments

Comments
 (0)