Skip to content

Commit

Permalink
style: fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Feb 26, 2024
1 parent 154994e commit 0a1c40a
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions lib/src/modules/macho/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,35 +796,32 @@ impl<'a> MachOFile<'a> {
let offset = blob_index.offset as usize;
let length = blob.length as usize;
let size_of_blob = std::mem::size_of::<CSBlob>();
match blob.magic {
CS_MAGIC_EMBEDDED_ENTITLEMENTS => {
let xml_data = &super_data
[offset + size_of_blob..offset + length];
let xml_string = std::str::from_utf8(xml_data)
.unwrap_or_default();

let opt = roxmltree::ParsingOptions {
allow_dtd: true,
..roxmltree::ParsingOptions::default()
};

if let Ok(parsed_xml) =
roxmltree::Document::parse_with_options(
xml_string, opt,
)
if blob.magic == CS_MAGIC_EMBEDDED_ENTITLEMENTS {
let xml_data = &super_data
[offset + size_of_blob..offset + length];
let xml_string = std::str::from_utf8(xml_data)
.unwrap_or_default();

let opt = roxmltree::ParsingOptions {
allow_dtd: true,
..roxmltree::ParsingOptions::default()
};

if let Ok(parsed_xml) =
roxmltree::Document::parse_with_options(
xml_string, opt,
)
{
for node in parsed_xml
.descendants()
.filter(|n| n.has_tag_name("key"))
{
for node in parsed_xml
.descendants()
.filter(|n| n.has_tag_name("key"))
{
if let Some(entitlement) = node.text() {
self.entitlements
.push(entitlement.to_string());
}
if let Some(entitlement) = node.text() {
self.entitlements
.push(entitlement.to_string());
}
}
}
_ => {}
}
}
}
Expand Down

0 comments on commit 0a1c40a

Please sign in to comment.