diff --git a/docs/format/container.md b/docs/format/container.md index 8ba76ff..4acba6f 100644 --- a/docs/format/container.md +++ b/docs/format/container.md @@ -17,6 +17,14 @@ against the local corpus (352 files, InDesign 3.0–21.6) and the fixtures. The file size is always a multiple of 4096. +**Truncated files.** In 4,251 of 4,252 distinct corpus files with the +signature and both master pages, the file is at least `db_pages × 4096` +bytes long. The other one (InDesign 13.1) is 12,288 bytes, 3 pages, +while both master pages give 129 database pages; it ends after its +first database page. The converter reports a file shorter than two +pages, or shorter than its active master page's database pages, as +truncated, with the number of bytes it needs. + ## Master pages Both master pages start with the header described in `header.md`. The one diff --git a/docs/format/fonts.md b/docs/format/fonts.md index d92ec32..3175db3 100644 --- a/docs/format/fonts.md +++ b/docs/format/fonts.md @@ -59,7 +59,13 @@ in-object string, and InDesign 3.0 has no version (`big-endian.md`). Codes 0 (54 fonts) and 3 (1 font) occur in files without an IDML; the converter leaves out `FontType` for them. - `WritingScript`: 4,464 of 4,464 with the u32 after the font records - (values 0, 1 and 33). + (values 0, 1 and 33). Over all 654 pairs later in the corpus, 30,406 + of 30,410 fonts; the other four, one family in one file, have 0 in the + INDD and 7 in the IDML. + One family in a file without an IDML stores `FF FF FF FF`. The schema + types `WritingScript` as `xsd:int`, and no corpus IDML has a negative + value, so the converter leaves the attribute out (with a warning) when + the u32 does not fit in an `int`. - `Name` is the family name, a space and the style name, and `Self` is the family's `Self`, `Fontn` and `Name` (4,464 of 4,464, taking the family name as IDML writes it). diff --git a/docs/format/header.md b/docs/format/header.md index 6320e1c..44c390c 100644 --- a/docs/format/header.md +++ b/docs/format/header.md @@ -25,6 +25,17 @@ bytes, multiples of 1,024 but not of 4,096), so the container below does not apply. The converter reports them as not supported. Files from 2.0 on start with the signature. +## Files that are not INDD + +Eleven distinct files in the corpus with an `.indd` or `.indt` name do +not start with the signature (nor with the InDesign 1.x layout). Their +first bytes show what they are: a PDF (`%PDF-1.5`), an AppleDouble +resource file from a `__MACOSX` folder (`00 05 16 07`, two copies), +eight short text placeholders (108 to 209 bytes) and a 5,000-byte file +that holds only the byte `04`. A 17-byte file holds the signature and +one more byte. The converter checks the signature before the file size, so it reports +the first group as not INDD files and the 17-byte file as truncated. + ## Other observations These are observations, not yet explanations. The page layout, master page diff --git a/docs/format/hyperlinks.md b/docs/format/hyperlinks.md index 3874350..7077df7 100644 --- a/docs/format/hyperlinks.md +++ b/docs/format/hyperlinks.md @@ -109,10 +109,16 @@ Over 41 destinations (39, plus 2 in a pair from another save): - `Name`, `DestinationUniqueKey` and `Hidden` (all true): 41 of 41. - `DestinationPage`: 39 of 39, and 0 of 2 in the other save. - Zoom 1 and `ViewPercentage="100"`: 39 of 39; the other two have 91 in - IDML, also with zoom 1. The converter writes the zoom × 100. -- View setting 1 and `ViewSetting="FitWindow"`: 41 of 41, the only - value. The converter writes `FitWindow` for 1 and leaves the attribute - out for other codes. + IDML, also with zoom 1. The converter writes the zoom × 100. Over the + 654 pairs of the later corpus: 1,157 of 1,159 destinations (33 files), + with values from 75.35 to 800. +- View setting 1 and `ViewSetting="FitWindow"`: 41 of 41, and 592 of 592 + in 26 files of the later corpus. View setting 0 and + `ViewSetting="Fixed"`: 567 of 567 in 11 files. The converter writes + these two and leaves the attribute out for other codes. +- One file without an IDML has three destinations with view setting 0 + and zoom 0. The schema allows `ViewPercentage` from 5 to 4000, so the + converter leaves it out (with a warning) for a zoom outside 0.05–40. - `NameManually="true"` in all 41 has no located field and is left out, as is the `ViewBounds` property. @@ -157,8 +163,17 @@ holds one text source (class 0x13502), the third one hyperlink (0x13501), and the four lists end the chunk. In two 4.0 files (big-endian) the second list holds 8 page destinations (0x13505) and the fourth 8 bookmarks (0x1354C); then come three empty lists, a count of 8 and eight -strings, not identified. The 6.0 layout above reads in all 1,203 -distinct 6.0–21.x files that have the chunk; no 5.0 file has it. +strings, not identified. The 6.0 layout above reads in all 4,075 +distinct 6.0–21.x files that have the chunk. + +InDesign 5.0 files use the 3.0 and 4.0 layout. 18 of the 108 distinct +5.0 files have the chunk, and in all 18 the four lists hold, in order, +text sources (classes 0x13502 and 0x13503), destinations (0x13504, +0x13505 and 0x13506), hyperlinks (0x13501) and bookmarks (0x1354C, in +3 files; empty in the others). Read with the 6.0 layout, 17 of them give +a list longer than the chunk. No 5.0 file has an IDML. Their page and +URL destination objects (109, in 17 of these files) end before the fields +described above, so the converter leaves them out with a warning. ## Order in designmap diff --git a/docs/format/objects.md b/docs/format/objects.md index 87274aa..848d12d 100644 --- a/docs/format/objects.md +++ b/docs/format/objects.md @@ -984,7 +984,7 @@ of the name: | Offset | Contents | IDML | Evidence | |---|---|---|---| -| 14 | f64 | `NeutralDensity` | 314 of 314 | +| 14 | f64 | `NeutralDensity` | 314 of 314 (2,786 of 2,786 over the 654 pairs of the later corpus) | | 26 | u32, one less than the IDML value | `TrapOrder` | 314 of 314 | | 32 | f64 | `Frequency` | 314 of 314 | | 40 | f64 | `Angle` | 314 of 314 (0, 15, 27, 45, 63 and 75) | @@ -995,6 +995,13 @@ is not known. `InkType="Normal"`, `PrintInk="true"` and that observation (`idml-values.md`). The schema puts inks after the colours and before the tints. +In 41 files without an IDML (InDesign 6.0, 13.x and 14.x, from two +font projects), the neutral density of all four process inks, their +only inks, is −1. The IDML schema allows 0.001 to 10 and no corpus IDML +shows what InDesign writes for such an ink, so the converter leaves +`NeutralDensity` out (with a warning) when the value is outside that +range. + ## Colour groups (0x1F39) Chunk 0x13C is a flag byte and the group name, chunk 0x1F60 a UID list diff --git a/docs/format/transparency.md b/docs/format/transparency.md index 8c1eabc..5b465b7 100644 --- a/docs/format/transparency.md +++ b/docs/format/transparency.md @@ -36,7 +36,7 @@ style on every attribute below. | 0x10816 | `BlendingSetting/Opacity` | f64, percent | 57 items in 4 files (40, 49, 50, 57, 69, 70) | | 0x10817 | `BlendingSetting/BlendMode` | i32 code (below) | 56 items in 4 files | | 0x1081A | `DropShadowSetting/Mode` | i32: 0 `None`, 1 `Drop` | 8 items with 1 in 2 files | -| 0x10820 | `DropShadowSetting/Size` | f64 | 6 items, two values | +| 0x10820 | `DropShadowSetting/Size` | f64 | 6 items, two values; 406 of 406 rectangles and text frames over the 654 pairs of the later corpus | | 0x1084D | `InnerShadowSetting/Applied` | u16: 1 true, 0 false | 10 items with 1 | | 0x1084E | `InnerShadowSetting/EffectColor` | swatch UID | 10 items (below) | | 0x10852 | `InnerShadowSetting/Distance` | f64 | 10 items with 0 | @@ -58,6 +58,12 @@ In pairs whose IDML is from an older version, 14 more items match on opacity and blend mode. One item there has 50 where the IDML says 100; that file was probably saved again after the export. +**Values outside the schema's range.** Four items in a file without an +IDML store a drop shadow size of −2.83; the schema allows 0 to 1000. +The converter leaves out any value of the attributes above that is +outside the schema's range, with a warning: sizes and distances 0–1000, +opacity 0–100, angles −180–180. + **Blend mode codes.** 1 `Multiply` (3 items), 3 `Overlay` (62), 9 `Lighten` (5); 0 `Normal` in all 576 object styles, whose IDML blend mode is `Normal`. These codes are the positions of the values in the IDML diff --git a/src/container.rs b/src/container.rs index 3245fbf..e0efe23 100644 --- a/src/container.rs +++ b/src/container.rs @@ -70,19 +70,30 @@ pub struct Container<'a> { impl<'a> Container<'a> { pub fn parse(bytes: &'a [u8]) -> Result, Error> { + // The signature first, so that a short file of another kind is + // reported as not an INDD file. + let first = Header::parse(&bytes[..bytes.len().min(PAGE_SIZE)])?; if bytes.len() < 2 * PAGE_SIZE { return Err(Error::Truncated { needed: 2 * PAGE_SIZE, got: bytes.len(), }); } - let first = Header::parse(&bytes[..PAGE_SIZE])?; Header::parse(&bytes[PAGE_SIZE..2 * PAGE_SIZE])?; let masters = [ MasterPage::parse(&bytes[..PAGE_SIZE]), MasterPage::parse(&bytes[PAGE_SIZE..2 * PAGE_SIZE]), ]; let active = usize::from(masters[1].sequence > masters[0].sequence); + // Every complete file holds at least its database pages + // (container.md). + let needed = masters[active].db_pages as usize * PAGE_SIZE; + if bytes.len() < needed { + return Err(Error::Truncated { + needed, + got: bytes.len(), + }); + } let header = if active == 0 { first } else { @@ -239,6 +250,25 @@ mod tests { contig(7, &data) } + #[test] + fn reports_missing_database_pages_as_truncated() { + let mut f = master(1, 129); + f.extend(master(0, 129)); + f.extend(vec![0u8; PAGE_SIZE]); + assert!(matches!( + Container::parse(&f), + Err(Error::Truncated { needed, got }) if needed == 129 * PAGE_SIZE && got == 3 * PAGE_SIZE + )); + } + + #[test] + fn reports_short_file_of_another_kind_as_not_indd() { + assert!(matches!( + Container::parse(b"%PDF-1.5 a short file of another kind"), + Err(Error::NotIndd) + )); + } + #[test] fn picks_master_with_higher_sequence() { let f = file([4, 5], &[]); diff --git a/src/idml/mod.rs b/src/idml/mod.rs index 4235338..d153ef4 100644 --- a/src/idml/mod.rs +++ b/src/idml/mod.rs @@ -884,6 +884,8 @@ struct Writer<'a> { name: String, /// Names of the enclosing style groups of each style or group UID. group_path: std::collections::HashMap>, + /// Values left out while writing, reported with the model's warnings. + warnings: std::cell::RefCell>, } fn group_paths(doc: &Document) -> std::collections::HashMap> { @@ -1170,10 +1172,18 @@ impl Writer<'_> { .attr("Self", d.reference()) .attr("Name", &d.name) .attr("DestinationPage", uref(Some(*page))); - if *view == 1 { - x.attr("ViewSetting", "FitWindow"); + match view { + 0 => { + x.attr("ViewSetting", "Fixed"); + } + 1 => { + x.attr("ViewSetting", "FitWindow"); + } + _ => {} + } + if let Some(zoom) = zoom { + x.attr("ViewPercentage", num(zoom * 100.0)); } - x.attr("ViewPercentage", num(zoom * 100.0)); } DestinationKind::Url { url } => { x.start("HyperlinkURLDestination") @@ -1397,22 +1407,24 @@ impl Writer<'_> { } // The schema puts inks after the colours. for i in &self.doc.inks { - x.empty( - "Ink", - &[ - ("Self", format!("Ink/{}", self_name(&i.name))), - ("Name", i.name.clone()), - ("Angle", num(i.angle)), - // These three are the same in every Ink of the corpus - // IDML files (idml-values.md). - ("ConvertToProcess", "false".into()), - ("Frequency", num(i.frequency)), - ("NeutralDensity", num(i.neutral_density)), - ("PrintInk", "true".into()), - ("TrapOrder", i.trap_order.to_string()), - ("InkType", "Normal".into()), - ], - ); + let mut attrs = vec![ + ("Self", format!("Ink/{}", self_name(&i.name))), + ("Name", i.name.clone()), + ("Angle", num(i.angle)), + // These three are the same in every Ink of the corpus + // IDML files (idml-values.md). + ("ConvertToProcess", "false".into()), + ("Frequency", num(i.frequency)), + ]; + if let Some(d) = i.neutral_density { + attrs.push(("NeutralDensity", num(d))); + } + attrs.extend([ + ("PrintInk", "true".into()), + ("TrapOrder", i.trap_order.to_string()), + ("InkType", "Normal".into()), + ]); + x.empty("Ink", &attrs); } for (t, reference, name) in &self.doc.tints { let base = self.doc.swatches.get(&t.base).cloned().unwrap_or_default(); @@ -1891,8 +1903,11 @@ impl Writer<'_> { if let Some(t) = font.type_name() { x.attr("FontType", t); } - x.attr("WritingScript", f.writing_script.to_string()) - .attr("FullName", &font.full_name) + // The schema's `xsd:int`; one file stores 0xFFFFFFFF (fonts.md). + if let Ok(w) = i32::try_from(f.writing_script) { + x.attr("WritingScript", w.to_string()); + } + x.attr("FullName", &font.full_name) .attr("FullNameNative", &font.full_name_native) .attr("FontStyleNameNative", &font.style_native) // `$ID/` in every Font of the corpus IDML files. @@ -2784,7 +2799,14 @@ impl Writer<'_> { ], ); } - transparency::write(x, &item.attrs, &uref(Some(item.uid)), &self.doc.swatches); + for (effect, attr, v) in + transparency::write(x, &item.attrs, &uref(Some(item.uid)), &self.doc.swatches) + { + self.warnings.borrow_mut().push(format!( + "item {}: {effect} {attr} {v} is outside the IDML range; left out", + item.uid + )); + } for child in &item.children { self.page_item(x, child); } @@ -3396,12 +3418,15 @@ impl TextState { } /// Write `doc` as an IDML package. `name` is the document name (file name). -pub fn write(doc: &Document, name: &str, out: impl std::io::Write) -> std::io::Result<()> { +/// Write `doc` as an IDML package. Returns warnings about values left out +/// because the IDML schema does not allow them. +pub fn write(doc: &Document, name: &str, out: impl std::io::Write) -> std::io::Result> { let w = Writer { doc, dom: format!("{}.0", doc.version.major), name: name.to_string(), group_path: group_paths(doc), + warnings: Default::default(), }; let mut files: BTreeMap = BTreeMap::new(); files.insert( @@ -3439,7 +3464,7 @@ pub fn write(doc: &Document, name: &str, out: impl std::io::Write) -> std::io::R z.add(path, content.as_bytes())?; } z.finish()?; - Ok(()) + Ok(w.warnings.into_inner()) } #[cfg(test)] @@ -3503,6 +3528,7 @@ mod tests { dom: "20.0".into(), name: String::new(), group_path: Default::default(), + warnings: Default::default(), }; let out: String = w .backing_story() diff --git a/src/idml/transparency.rs b/src/idml/transparency.rs index 42a169d..a744905 100644 --- a/src/idml/transparency.rs +++ b/src/idml/transparency.rs @@ -10,6 +10,8 @@ use crate::object::{f64_from, u32_at}; #[derive(Clone, Copy)] enum Kind { Number, + /// A number the IDML schema limits to this range (inclusive). + Range(f64, f64), Bool, Point, Enum(&'static [(u32, &'static str)]), @@ -55,7 +57,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[ "TransparencySetting", "BlendingSetting", "Opacity", - Kind::Number, + Kind::Range(0.0, 100.0), ), ( 0x1081A, @@ -69,7 +71,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[ "TransparencySetting", "DropShadowSetting", "Size", - Kind::Number, + Kind::Range(0.0, 1000.0), ), ( 0x1084D, @@ -90,14 +92,14 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[ "TransparencySetting", "InnerShadowSetting", "Distance", - Kind::Number, + Kind::Range(0.0, 1000.0), ), ( 0x10855, "TransparencySetting", "InnerShadowSetting", "Size", - Kind::Number, + Kind::Range(0.0, 1000.0), ), ( 0x1EB8A, @@ -111,7 +113,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[ "TransparencySetting", "GradientFeatherSetting", "Angle", - Kind::Number, + Kind::Range(-180.0, 180.0), ), ( 0x1EB8E, @@ -153,7 +155,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[ "StrokeTransparencySetting", "GradientFeatherSetting", "Angle", - Kind::Number, + Kind::Range(-180.0, 180.0), ), ( 0x1EB97, @@ -181,7 +183,7 @@ const ATTRS: &[(u32, &str, &str, &str, Kind)] = &[ "FillTransparencySetting", "GradientFeatherSetting", "Angle", - Kind::Number, + Kind::Range(-180.0, 180.0), ), ( 0x1EBA0, @@ -249,8 +251,19 @@ fn stops(data: &[u8]) -> Option> { ) } -fn value(v: &Value, kind: Kind, swatches: &BTreeMap) -> Option { - match kind { +/// A value as IDML text; `Err` with the value when it is outside the +/// schema's range. +fn value(v: &Value, kind: Kind, swatches: &BTreeMap) -> Option> { + if let Kind::Range(lo, hi) = kind { + let f = v.as_f64()?; + return Some(if (lo..=hi).contains(&f) { + Ok(num(f)) + } else { + Err(f) + }); + } + Some(Ok(match kind { + Kind::Range(..) => unreachable!(), Kind::Number => v.as_f64().map(num), Kind::Bool => match v.as_u32()? { 0 => Some("false".into()), @@ -268,12 +281,20 @@ fn value(v: &Value, kind: Kind, swatches: &BTreeMap) -> Option v.as_ref().and_then(|u| swatches.get(&u).cloned()), - } + }?)) } /// Write the transparency settings found in a page item's attribute list. -/// `item` is the item's `Self`, which names the opacity stops. -pub(super) fn write(x: &mut Xml, attrs: &Attrs, item: &str, swatches: &BTreeMap) { +/// `item` is the item's `Self`, which names the opacity stops. Returns the +/// values left out because they are outside the schema's range, as +/// (effect, attribute, value). +pub(super) fn write( + x: &mut Xml, + attrs: &Attrs, + item: &str, + swatches: &BTreeMap, +) -> Vec<(&'static str, &'static str, f64)> { + let mut left_out = Vec::new(); let inner_shadow_applied = attrs.get(INNER_SHADOW_APPLIED).and_then(Value::as_u32) == Some(1); for &setting in SETTINGS { let mut effects: Vec = Vec::new(); @@ -286,8 +307,10 @@ pub(super) fn write(x: &mut Xml, attrs: &Attrs, item: &str, swatches: &BTreeMap< if matches!(kind, Kind::Swatch) && !inner_shadow_applied { continue; } - if let Some(t) = attrs.get(id).and_then(|v| value(v, kind, swatches)) { - values.push((name, t)); + match attrs.get(id).and_then(|v| value(v, kind, swatches)) { + Some(Ok(t)) => values.push((name, t)), + Some(Err(f)) => left_out.push((effect, name, f)), + None => {} } } let stop_list = if effect == "GradientFeatherSetting" { @@ -332,6 +355,7 @@ pub(super) fn write(x: &mut Xml, attrs: &Attrs, item: &str, swatches: &BTreeMap< } x.end(); } + left_out } #[cfg(test)] diff --git a/src/lib.rs b/src/lib.rs index 56c9c2c..43e7994 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,6 +20,7 @@ pub enum Error { Io(std::io::Error), /// The file does not start with the INDD signature. NotIndd, + /// The file is shorter than its header or its database pages say. Truncated { needed: usize, got: usize, @@ -47,7 +48,7 @@ impl std::fmt::Display for Error { Error::Io(e) => write!(f, "{e}"), Error::NotIndd => write!(f, "not an INDD file"), Error::Truncated { needed, got } => { - write!(f, "file too short: need {needed} bytes, got {got}") + write!(f, "file truncated: need {needed} bytes, got {got}") } Error::UnknownByteOrder(b) => write!(f, "unknown byte-order flag {b:#04x}"), Error::BadContigObject { offset } => { @@ -109,6 +110,7 @@ pub fn convert(indd: &[u8], name: &str, out: impl std::io::Write) -> Result, pub trap_order: u32, pub frequency: f64, pub angle: f64, @@ -406,7 +408,7 @@ impl Ink { Ok(Some(Ink { uid, name: if builtin { format!("$ID/{name}") } else { name }, - neutral_density: f(14)?, + neutral_density: Some(f(14)?).filter(|v| (0.001..=10.0).contains(v)), trap_order: Cursor::new(&d[end + 26..]).u32()? + 1, frequency: f(32)?, angle: f(40)?, diff --git a/src/model/hyperlink.rs b/src/model/hyperlink.rs index 68b65a2..d2b2e60 100644 --- a/src/model/hyperlink.rs +++ b/src/model/hyperlink.rs @@ -74,8 +74,9 @@ const TOC_ANCHOR: [u8; 21] = [ pub enum DestinationKind { Page { page: u32, - /// View zoom as a fraction (1 = 100 %). - zoom: f64, + /// View zoom as a fraction (1 = 100 %). `None` when outside the + /// 5–4000 % the IDML schema allows (0 in some files). + zoom: Option, /// View setting code. view: u32, }, @@ -203,7 +204,7 @@ impl Destination { }; let mut c = Cursor::new(v); let page = c.u32()?; - let zoom = c.f64()?; + let zoom = Some(c.f64()?).filter(|z| (0.05..=40.0).contains(z)); let view = c.u32()?; DestinationKind::Page { page, zoom, view } } else { @@ -246,11 +247,11 @@ impl Bookmark { /// The bookmark list in document chunk 0x13501. From InDesign 6.0: u32, /// u16, then UID lists of text sources, hyperlinks and bookmarks. In 3.0 -/// and 4.0 files: UID lists of text sources, destinations, hyperlinks and +/// to 5.0 files: UID lists of text sources, destinations, hyperlinks and /// bookmarks (`docs/format/hyperlinks.md`). pub fn document_bookmarks(data: &[u8], major: u32) -> Result, Error> { let mut c = Cursor::new(data); - if major <= 4 { + if major <= 5 { for _ in 0..3 { c.u32_list()?; } diff --git a/src/model/mod.rs b/src/model/mod.rs index 4cac88e..0195410 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -940,6 +940,13 @@ impl<'a> Reader<'a> { } class::FONT_FAMILY => match FontFamily::read(uid, &*self.object(uid)?) { Ok(Some(f)) => { + if i32::try_from(f.writing_script).is_err() { + self.warn(format!( + "font family {uid}: writing script {:#x} is not an IDML \ + integer; left out", + f.writing_script + )); + } fonts.insert(uid, f); } Ok(None) => {} @@ -976,6 +983,11 @@ impl<'a> Reader<'a> { } hyperlink::class::PAGE_DESTINATION | hyperlink::class::URL_DESTINATION => { if let Some(d) = Destination::read(uid, cls, &*self.object(uid)?)? { + if let hyperlink::DestinationKind::Page { zoom: None, .. } = d.kind { + self.warn(format!( + "destination {uid}: view zoom is outside 5–4000 %; left out" + )); + } destinations.push(d); } } @@ -1006,6 +1018,11 @@ impl<'a> Reader<'a> { } color::class::INK => { if let Some(i) = Ink::read(uid, &*self.object(uid)?)? { + if i.neutral_density.is_none() { + self.warn(format!( + "ink {uid}: neutral density is outside 0.001–10; left out" + )); + } inks.push(i); } } diff --git a/tests/corpus.rs b/tests/corpus.rs index 759cffe..8c85501 100644 --- a/tests/corpus.rs +++ b/tests/corpus.rs @@ -4,9 +4,12 @@ //! `corpus/exclude.txt` (local, optional) lists paths under `corpus/` to //! leave out, one per line, for example a folder still being downloaded. //! -//! Two kinds of file cannot be converted, and the tests accept them: the -//! InDesign 1.x layout ([`indd::Error::Unsupported`], `header.md`) and files -//! without an object database ([`indd::Error::NoDatabase`], `database.md`). +//! Some files cannot be converted, and the tests accept them: the +//! InDesign 1.x layout ([`indd::Error::Unsupported`], `header.md`), files +//! without an object database ([`indd::Error::NoDatabase`], `database.md`), +//! files with an INDD name that are something else ([`indd::Error::NotIndd`]) +//! and files shorter than their header or database pages say +//! ([`indd::Error::Truncated`], `container.md`). use std::path::{Path, PathBuf}; @@ -36,7 +39,10 @@ fn corpus_files(root: &Path) -> Vec { fn known_unreadable(e: &indd::Error) -> bool { matches!( e, - indd::Error::Unsupported(_) | indd::Error::NoDatabase { .. } + indd::Error::Unsupported(_) + | indd::Error::NoDatabase { .. } + | indd::Error::NotIndd + | indd::Error::Truncated { .. } ) }