diff options
author | Roman Frołow <rofrol@gmail.com> | 2021-01-04 04:21:49 +0100 |
---|---|---|
committer | Roman Frołow <rofrol@gmail.com> | 2021-01-04 04:54:04 +0100 |
commit | 482d58e47791009ddf7bdeb1dec254bc0028f3dc (patch) | |
tree | cca902c6857c9557dd5c361f5e13c4c1d5e78d91 /src | |
parent | f20adc60a3dcc744a3adbd40ba6aa6917f06d9c7 (diff) | |
download | bk-482d58e47791009ddf7bdeb1dec254bc0028f3dc.tar.gz |
allow_dtd
Diffstat (limited to 'src')
-rw-r--r-- | src/epub.rs | 6 |
1 files changed, 4 insertions, 2 deletions
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 { |