Skip to content

Commit

Permalink
Merge pull request #473 from PrettyWood/bump-quick-xml
Browse files Browse the repository at this point in the history
build(deps): bump quick-xml to 0.36
  • Loading branch information
tafia authored Oct 30, 2024
2 parents 1bb0b11 + 9dd38b7 commit c806996
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
38 changes: 20 additions & 18 deletions src/ods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ fn check_for_password_protected<RS: Read + Seek>(zip: &mut ZipArchive<RS>) -> 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")),
Expand Down Expand Up @@ -287,10 +288,11 @@ fn parse_content<RS: Read + Seek>(mut zip: ZipArchive<RS>) -> Result<Content, Od
let mut reader = match zip.by_name("content.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("content.xml")),
Expand All @@ -307,7 +309,7 @@ fn parse_content<RS: Read + Seek>(mut zip: ZipArchive<RS>) -> Result<Content, Od
Ok(Event::Start(ref e)) if e.name() == QName(b"style:style") => {
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())
Expand All @@ -317,7 +319,7 @@ fn parse_content<RS: Read + Seek>(mut zip: ZipArchive<RS>) -> Result<Content, Od
{
let visible = match e.try_get_attribute(b"table:display")? {
Some(a) => match a
.decode_and_unescape_value(&reader)
.decode_and_unescape_value(reader.decoder())
.map_err(OdsError::Xml)?
.parse()
.map_err(OdsError::ParseBool)?
Expand All @@ -333,7 +335,7 @@ fn parse_content<RS: Read + Seek>(mut zip: ZipArchive<RS>) -> Result<Content, Od
let visible = styles
.get(
&e.try_get_attribute(b"table: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()),
Expand All @@ -346,7 +348,7 @@ fn parse_content<RS: Read + Seek>(mut zip: ZipArchive<RS>) -> Result<Content, Od
.find(|a| a.key == QName(b"table:name"))
{
let name = a
.decode_and_unescape_value(&reader)
.decode_and_unescape_value(reader.decoder())
.map_err(OdsError::Xml)?
.to_string();
let (range, formulas) = read_table(&mut reader)?;
Expand Down Expand Up @@ -388,7 +390,7 @@ fn read_table(reader: &mut OdsReader<'_>) -> Result<(Range<Data>, Range<String>)
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)?,
Expand Down Expand Up @@ -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 {
Expand All @@ -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();
}
Expand Down Expand Up @@ -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)?,
Expand Down Expand Up @@ -701,13 +703,13 @@ fn read_named_expressions(reader: &mut OdsReader<'_>) -> Result<Vec<(String, Str
match a.key {
QName(b"table:name") => {
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();
}
Expand Down
9 changes: 5 additions & 4 deletions src/xlsb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,11 @@ impl<RS: Read + Seek> Xlsb<RS> {
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<u8> = Vec::with_capacity(64);

loop {
Expand Down
18 changes: 10 additions & 8 deletions src/xlsx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,14 @@ impl<RS: Read + Seek> Xlsx<RS> {
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,
Expand Down Expand Up @@ -393,7 +394,7 @@ impl<RS: Read + Seek> Xlsx<RS> {
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(),
),
Expand All @@ -406,7 +407,7 @@ impl<RS: Read + Seek> Xlsx<RS> {
.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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c806996

Please sign in to comment.