mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-18 16:14:57 +00:00
XLSX: a damaged Python part is a warning, and the workbook opens with its values
A Python part whose zip entry failed to read (a bad checksum or compressed stream) made the whole workbook fail to open: the error was passed up, and the failed read had also ended the package's read budget, so even a warning would have left the sheets unread. The part is now read with Package::read_optional_limited, which charges a failed read only that part's allowance, and every error other than TooLarge is a warning. The Python cells then keep only their cached values, as when the part is missing. Malformed XML in the part was already a warning; the test covers it too.
This commit is contained in:
1 parent
44e9ddad45
commit
113aeff07c
3 files changed
+92
-2
No files matched your search
@@ -71,7 +71,7 @@ impl ScriptsIn {
|
||||
pub fn read(cx: &mut Ctx<'_>, rels: &[crate::package::Rel]) -> Result<ScriptsIn, IoError> {
|
||||
let mut out = ScriptsIn { budget: MAX_CODE_BYTES, ..ScriptsIn::default() };
|
||||
let Some(rel) = rels.iter().find(|r| !r.external && r.kind.eq_ignore_ascii_case(REL_KIND)) else { return Ok(out) };
|
||||
let bytes = match cx.pkg.read_limited(&rel.target, MAX_PART_BYTES) {
|
||||
let bytes = match cx.pkg.read_optional_limited(&rel.target, MAX_PART_BYTES) {
|
||||
Ok(Some(b)) => b,
|
||||
Ok(None) => {
|
||||
cx.warn(format!("missing part {}", rel.target));
|
||||
@@ -81,7 +81,12 @@ pub fn read(cx: &mut Ctx<'_>, rels: &[crate::package::Rel]) -> Result<ScriptsIn,
|
||||
cx.warn(format!("the Python part is too large ({m}); Python cells kept only their values"));
|
||||
return Ok(out);
|
||||
}
|
||||
Err(e) => return Err(e),
|
||||
// A damaged entry (a bad checksum or compressed stream) is a damaged part: its cells keep
|
||||
// their values, as when the part is missing.
|
||||
Err(e) => {
|
||||
cx.warn(format!("the Python part is damaged ({e}); Python cells kept only their values"));
|
||||
return Ok(out);
|
||||
}
|
||||
};
|
||||
let mut over = 0usize;
|
||||
let parsed = xml::parse_streaming(&bytes, &["pythonScript"], &mut |el: El| {
|
||||
|
||||
Reference in new issue
Block a user