From b4869607205b5e50add4523b257f8bae6f954458 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 18 Jan 2016 22:26:23 +0100 Subject: [PATCH] Add version-string verification --- libimagstore/src/header.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libimagstore/src/header.rs b/libimagstore/src/header.rs index 5a086990..74f8b748 100644 --- a/libimagstore/src/header.rs +++ b/libimagstore/src/header.rs @@ -138,12 +138,16 @@ fn has_main_section(t: &Table) -> bool { } fn has_imag_version_in_main_section(t: &Table) -> bool { + use regex::Regex; + match t.get("imag").unwrap() { &Value::Table(ref sec) => { sec.get("version") .and_then(|v| { match v { - &Value::String(_) => Some(true), + &Value::String(ref s) => { + Some(Regex::new(r"^\d{1}\.\d{1}\.\d{1}(.*)").unwrap().is_match(&s[..])) + }, _ => Some(false), } })