diff --git a/Cargo.toml b/Cargo.toml index c785579..f582d81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ codepage = "0.1.1" encoding_rs = "0.8" log = "0.4" serde = "1.0" -quick-xml = { version = "0.31", features = ["encoding"] } +quick-xml = { version = "0.36", features = ["encoding"] } zip = { version = "2", default-features = false, features = ["deflate"] } chrono = { version = "0.4", features = [ "serde", diff --git a/src/ods.rs b/src/ods.rs index 1021abb..fd79e4e 100644 --- a/src/ods.rs +++ b/src/ods.rs @@ -243,10 +243,11 @@ fn check_for_password_protected(zip: &mut ZipArchive) -> Re let mut reader = match zip.by_name("META-INF/manifest.xml") { Ok(f) => { let mut r = XmlReader::from_reader(BufReader::new(f)); - r.check_end_names(false) - .trim_text(false) - .check_comments(false) - .expand_empty_elements(true); + let config = r.config_mut(); + config.check_end_names = false; + config.trim_text(false); + config.check_comments = false; + config.expand_empty_elements = true; r } Err(ZipError::FileNotFound) => return Err(OdsError::FileNotFound("META-INF/manifest.xml")), @@ -287,10 +288,11 @@ fn parse_content(mut zip: ZipArchive) -> Result { let mut r = XmlReader::from_reader(BufReader::new(f)); - r.check_end_names(false) - .trim_text(false) - .check_comments(false) - .expand_empty_elements(true); + let config = r.config_mut(); + config.check_end_names = false; + config.trim_text(false); + config.check_comments = false; + config.expand_empty_elements = true; r } Err(ZipError::FileNotFound) => return Err(OdsError::FileNotFound("content.xml")), @@ -307,7 +309,7 @@ fn parse_content(mut zip: ZipArchive) -> Result { style_name = e .try_get_attribute(b"style:name")? - .map(|a| a.decode_and_unescape_value(&reader)) + .map(|a| a.decode_and_unescape_value(reader.decoder())) .transpose() .map_err(OdsError::Xml)? .map(|x| x.to_string()) @@ -317,7 +319,7 @@ fn parse_content(mut zip: ZipArchive) -> Result match a - .decode_and_unescape_value(&reader) + .decode_and_unescape_value(reader.decoder()) .map_err(OdsError::Xml)? .parse() .map_err(OdsError::ParseBool)? @@ -333,7 +335,7 @@ fn parse_content(mut zip: ZipArchive) -> Result(mut zip: ZipArchive) -> Result) -> Result<(Range, Range) Ok(Event::Start(ref e)) if e.name() == QName(b"table:table-row") => { let row_repeats = match e.try_get_attribute(b"table:number-rows-repeated")? { Some(c) => c - .decode_and_unescape_value(reader) + .decode_and_unescape_value(reader.decoder()) .map_err(OdsError::Xml)? .parse() .map_err(OdsError::ParseInt)?, @@ -603,7 +605,7 @@ fn get_datatype( if !is_value_set => { let attr = a - .decode_and_unescape_value(reader) + .decode_and_unescape_value(reader.decoder()) .map_err(OdsError::Xml)? .to_string(); val = match a.key { @@ -621,7 +623,7 @@ fn get_datatype( QName(b"office:value-type") if !is_value_set => is_string = &*a.value == b"string", QName(b"table:formula") => { formula = a - .decode_and_unescape_value(reader) + .decode_and_unescape_value(reader.decoder()) .map_err(OdsError::Xml)? .to_string(); } @@ -664,7 +666,7 @@ fn get_datatype( Ok(Event::Start(ref e)) if e.name() == QName(b"text:s") => { let count = match e.try_get_attribute("text:c")? { Some(c) => c - .decode_and_unescape_value(reader) + .decode_and_unescape_value(reader.decoder()) .map_err(OdsError::Xml)? .parse() .map_err(OdsError::ParseInt)?, @@ -701,13 +703,13 @@ fn read_named_expressions(reader: &mut OdsReader<'_>) -> Result { name = a - .decode_and_unescape_value(reader) + .decode_and_unescape_value(reader.decoder()) .map_err(OdsError::Xml)? .to_string(); } QName(b"table:cell-range-address" | b"table:expression") => { formula = a - .decode_and_unescape_value(reader) + .decode_and_unescape_value(reader.decoder()) .map_err(OdsError::Xml)? .to_string(); } diff --git a/src/xlsb/mod.rs b/src/xlsb/mod.rs index 364bf6e..fca4bed 100644 --- a/src/xlsb/mod.rs +++ b/src/xlsb/mod.rs @@ -159,10 +159,11 @@ impl Xlsb { match self.zip.by_name("xl/_rels/workbook.bin.rels") { Ok(f) => { let mut xml = XmlReader::from_reader(BufReader::new(f)); - xml.check_end_names(false) - .trim_text(false) - .check_comments(false) - .expand_empty_elements(true); + let config = xml.config_mut(); + config.check_end_names = false; + config.trim_text(false); + config.check_comments = false; + config.expand_empty_elements = true; let mut buf: Vec = Vec::with_capacity(64); loop { diff --git a/src/xlsx/mod.rs b/src/xlsx/mod.rs index 78d74dd..802a071 100644 --- a/src/xlsx/mod.rs +++ b/src/xlsx/mod.rs @@ -330,13 +330,14 @@ impl Xlsx { key: QName(b"name"), .. } => { - name = a.decode_and_unescape_value(&xml)?.to_string(); + name = a.decode_and_unescape_value(xml.decoder())?.to_string(); } Attribute { key: QName(b"state"), .. } => { - visible = match a.decode_and_unescape_value(&xml)?.as_ref() { + visible = match a.decode_and_unescape_value(xml.decoder())?.as_ref() + { "visible" => SheetVisible::Visible, "hidden" => SheetVisible::Hidden, "veryHidden" => SheetVisible::VeryHidden, @@ -393,7 +394,7 @@ impl Xlsx { Ok(Event::Start(ref e)) if e.name().as_ref() == b"workbookPr" => { self.is_1904 = match e.try_get_attribute("date1904")? { Some(c) => ["1", "true"].contains( - &c.decode_and_unescape_value(&xml) + &c.decode_and_unescape_value(xml.decoder()) .map_err(XlsxError::Xml)? .as_ref(), ), @@ -406,7 +407,7 @@ impl Xlsx { .filter_map(std::result::Result::ok) .find(|a| a.key == QName(b"name")) { - let name = a.decode_and_unescape_value(&xml)?.to_string(); + let name = a.decode_and_unescape_value(xml.decoder())?.to_string(); val_buf.clear(); let mut value = String::new(); loop { @@ -1088,10 +1089,11 @@ fn xml_reader<'a, RS: Read + Seek>( match zip.by_name(&actual_path) { Ok(f) => { let mut r = XmlReader::from_reader(BufReader::new(f)); - r.check_end_names(false) - .trim_text(false) - .check_comments(false) - .expand_empty_elements(true); + let config = r.config_mut(); + config.check_end_names = false; + config.trim_text(false); + config.check_comments = false; + config.expand_empty_elements = true; Some(Ok(r)) } Err(ZipError::FileNotFound) => None,