From 482d58e47791009ddf7bdeb1dec254bc0028f3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Mon, 4 Jan 2021 04:21:49 +0100 Subject: allow_dtd --- src/epub.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/epub.rs b/src/epub.rs index 9fb2adc..ff78918 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -1,6 +1,6 @@ use anyhow::Result; use crossterm::style::{Attribute, Attributes}; -use roxmltree::{Document, Node}; +use roxmltree::{Document, Node, ParsingOptions}; use std::{collections::HashMap, fs::File, io::Read}; pub struct Chapter { @@ -51,9 +51,11 @@ impl Epub { fn get_chapters(&mut self, spine: Vec<(String, String)>) { for (title, path) in spine { let xml = self.get_text(&format!("{}{}", self.rootdir, path)); + let opt = ParsingOptions { allow_dtd: true }; // https://github.com/RazrFalcon/roxmltree/issues/12 // UnknownEntityReference for HTML entities - let doc = Document::parse(&xml).unwrap(); + let doc = Document::parse_with_options(&xml, opt) + .unwrap_or_else(|_| panic!("Could not parse path: {}", &path)); let body = doc.root_element().last_element_child().unwrap(); let state = Attributes::default(); let mut c = Chapter { -- cgit v1.2.3