diff --git a/rust/passgen/src/resolution792.rs b/rust/passgen/src/resolution792.rs index 3379a23ac3..79244c52c9 100644 --- a/rust/passgen/src/resolution792.rs +++ b/rust/passgen/src/resolution792.rs @@ -351,23 +351,25 @@ impl BoardingPass { boarding_pass.legs.push(leg); } - // What's left is the security data. - if data[p] != b'^' { - return Err(anyhow!( - "expected security data beginning indicator (^) but got {} ({})", - data[p], - data[p] as char - )); - } - boarding_pass.security_data_type = data[p + 1]; - let security_data_size: usize = - usize::from_str_radix(std::str::from_utf8(&data[p + 2..p + 4])?, 16)?; - boarding_pass.security_data = data[p + 4..p + 4 + security_data_size].to_vec(); - if data.len() > p + 4 + security_data_size { - return Err(anyhow!( - "trailing bytes after security data (expected {} bytes of security data)", - security_data_size - )); + if data.len() > p { + // What's left is the security data. + if data[p] != b'^' { + return Err(anyhow!( + "expected security data beginning indicator (^) but got {} ({})", + data[p], + data[p] as char + )); + } + boarding_pass.security_data_type = data[p + 1]; + let security_data_size: usize = + usize::from_str_radix(std::str::from_utf8(&data[p + 2..p + 4])?, 16)?; + boarding_pass.security_data = data[p + 4..p + 4 + security_data_size].to_vec(); + if data.len() > p + 4 + security_data_size { + return Err(anyhow!( + "trailing bytes after security data (expected {} bytes of security data)", + security_data_size + )); + } } Ok(boarding_pass) @@ -397,6 +399,7 @@ pub struct BoardingPassLeg { pub frequent_flyer_number: Option, pub id_ad_indicator: Option, pub free_baggage_allowance: Option, + pub fast_track: Option, pub airline_data: Option>, } @@ -444,6 +447,7 @@ impl BoardingPassLeg { frequent_flyer_number: None, id_ad_indicator: None, free_baggage_allowance: None, + fast_track: None, airline_data: None, }, 35, @@ -537,6 +541,14 @@ impl BoardingPassLeg { }; structured_data = &structured_data[3..]; } + if !structured_data.is_empty() { + self.fast_track = if structured_data[0] == b' ' { + None + } else { + Some(structured_data[0] as char) + }; + structured_data = &structured_data[1..]; + } if !structured_data.is_empty() { return Err(anyhow!( "trailing data in structured data section ({} bytes)",