From da77983228cfae45cfd4f8fc66b75919f67014ae Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 12 Nov 2024 10:37:01 +0100 Subject: [PATCH] get_rootfile() simplified --- Cargo.lock | 2 +- src/epub.rs | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1e7a0f..dd0508f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,7 +396,7 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "pbdbfixer" -version = "0.8.3" +version = "0.9.0" dependencies = [ "quick-xml", "rusqlite", diff --git a/src/epub.rs b/src/epub.rs index 3574377..82d67bc 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -61,18 +61,17 @@ fn get_rootfile(archive: &mut ZipArchive) -> String { loop { match reader.read_event_into(&mut buf) { Ok(Event::Start(ref e)) | Ok(Event::Empty(ref e)) - if e.local_name().into_inner() == b"rootfile" => + if e.name().as_ref() == b"rootfile" => { - opf_filename = String::from_utf8( - e.attributes() - .filter(|attr| attr.as_ref().unwrap().key.into_inner() == b"full-path") - .next() - .unwrap() - .unwrap() - .value - .to_vec(), - ) - .unwrap(); + opf_filename = e + .attributes() + .filter(|attr| attr.as_ref().unwrap().key.as_ref() == b"full-path") + .next() + .unwrap() + .unwrap() + .unescape_value() + .unwrap() + .to_string(); break; } Ok(Event::Eof) => break,