Missing ':' delimiter when using "zero pad" flag
ctron opened this issue · comments
Jens Reimann commented
When using the zero pad flag ({cpe:0}
) not only the value, but also the :
is being omitted.
Which might lead to fields being shifted. For example:
#[test]
fn test_zero() {
use cpe::cpe::Cpe;
let original = "cpe:/a:foo:bar:1.2::x";
let parsed = OwnedUri::from_str(original).unwrap();
let formatted = format!("{parsed:0}");
let reparsed = OwnedUri::from_str(&formatted).unwrap();
assert_eq!(parsed.part(), reparsed.part());
assert_eq!(parsed.vendor(), reparsed.vendor());
assert_eq!(parsed.product(), reparsed.product());
assert_eq!(parsed.version(), reparsed.version());
assert_eq!(parsed.update(), reparsed.update());
assert_eq!(parsed.edition(), reparsed.edition());
}
The test will fail for:
assert_eq!(parsed.update(), reparsed.update());
With:
assertion `left == right` failed
left: Any
right: Value("x")
Left: Any
Right: Value("x")
As the value shifted:
- Original:
cpe:/a:foo:bar:1.2::x
- Formatted:
cpe:/a:foo:bar:1.2:x