diff options
| author | James Campos <james.r.campos@gmail.com> | 2021-01-04 15:51:56 -0800 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-04 15:51:56 -0800 | 
| commit | 94481d475f05ce12dde84c499f6f9a1be420df89 (patch) | |
| tree | 03fce7972db6ac578a0f45294209280774f39785 | |
| parent | dcf3178721beae1a98a6d1030f1f679be7d819f1 (diff) | |
| parent | 482d58e47791009ddf7bdeb1dec254bc0028f3dc (diff) | |
| download | bk-94481d475f05ce12dde84c499f6f9a1be420df89.tar.gz | |
Merge pull request #14 from rofrol/allow_dtd
allow_dtd
| -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 { | 
