verso-reader 0.1.0

A terminal EPUB reader with vim navigation, a Kindle-style library, and Markdown highlight export
Documentation
use verso::library::epub_guard::{validate_archive, GuardError, Limits};

#[test]
fn time_machine_passes_guards() {
    validate_archive(
        std::path::Path::new("tests/fixtures/time-machine.epub"),
        Limits::default(),
    )
    .unwrap();
}

#[test]
fn rejects_path_traversal() {
    // Build a tiny ZIP with a ../foo entry.
    let tmp = tempfile::NamedTempFile::new().unwrap();
    {
        let file = std::fs::File::create(tmp.path()).unwrap();
        let mut zip = zip::ZipWriter::new(file);
        zip.start_file("../evil.txt", zip::write::FileOptions::default())
            .unwrap();
        use std::io::Write;
        zip.write_all(b"nope").unwrap();
        zip.finish().unwrap();
    }
    let err = validate_archive(tmp.path(), Limits::default()).unwrap_err();
    assert!(matches!(err, GuardError::PathTraversal(_)));
}