detect/integers: support kibibyte unit

Ticket: 7869
pull/13767/head
Philippe Antoine 2 months ago committed by Victor Julien
parent be9858d3aa
commit d0a513df6a

@ -15,9 +15,9 @@ an hexadecimal value like ``0x64``.
The integer value can also have a unit/multiplier as a The integer value can also have a unit/multiplier as a
case-insensitive suffix: case-insensitive suffix:
* kb : 1024 * kb/kib : 1024
* mb : 1048576 * mb/mib : 1048576
* gb : 1073741824 * gb/gib : 1073741824
The most direct example is to match for equality, but there are The most direct example is to match for equality, but there are
different modes. different modes.

@ -104,8 +104,11 @@ impl<T> DetectIntType for T where
pub fn detect_parse_uint_unit(i: &str) -> IResult<&str, u64> { pub fn detect_parse_uint_unit(i: &str) -> IResult<&str, u64> {
let (i, unit) = alt(( let (i, unit) = alt((
value(1024, tag_no_case("kib")),
value(1024, tag_no_case("kb")), value(1024, tag_no_case("kb")),
value(1024 * 1024, tag_no_case("mib")),
value(1024 * 1024, tag_no_case("mb")), value(1024 * 1024, tag_no_case("mb")),
value(1024 * 1024 * 1024, tag_no_case("gib")),
value(1024 * 1024 * 1024, tag_no_case("gb")), value(1024 * 1024 * 1024, tag_no_case("gb")),
))(i)?; ))(i)?;
return Ok((i, unit)); return Ok((i, unit));

Loading…
Cancel
Save