aboutsummaryrefslogtreecommitdiffstats
path: root/src/epub.rs
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2021-01-04 15:51:56 -0800
committerGitHub <noreply@github.com>2021-01-04 15:51:56 -0800
commit94481d475f05ce12dde84c499f6f9a1be420df89 (patch)
tree03fce7972db6ac578a0f45294209280774f39785 /src/epub.rs
parentdcf3178721beae1a98a6d1030f1f679be7d819f1 (diff)
parent482d58e47791009ddf7bdeb1dec254bc0028f3dc (diff)
downloadbk-94481d475f05ce12dde84c499f6f9a1be420df89.tar.gz
Merge pull request #14 from rofrol/allow_dtd
allow_dtd
Diffstat (limited to 'src/epub.rs')
-rw-r--r--src/epub.rs6
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 {