mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-15 15:22:54 +00:00
M2.6: autotagging's reason for content it can't decode reads as on main
Since autotagging reads page content through DecodeBudget::decode_strict, the reason it gave for content that doesn't decode carried that error's own text, so it said twice that the data couldn't be decoded: "content cannot be decoded strictly: stream data could not be decoded: FlateDecode: …". It now gives the decoder's reason right after, as main does: "content cannot be decoded strictly: FlateDecode: …". Test: autotag_text_says_why_it_cannot_read_a_page now checks the decoder's reason follows the prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
This commit is contained in:
1 parent
104e22904a
commit
d1de0a4bad
2 files changed
+9
-3
No files matched your search
@@ -66,7 +66,13 @@ fn content_bytes(doc: &Document, page: &pdfcraft_model::Page, index: usize) -> R
|
||||
if budget.remaining() == 0 {
|
||||
unsupported(index, "decoding the content takes more than 16 MiB")
|
||||
} else {
|
||||
unsupported(index, format!("content cannot be decoded strictly: {e}"))
|
||||
// The decoder's own reason: `CosError::Filter`'s text would say again that the data
|
||||
// couldn't be decoded.
|
||||
let why = match e {
|
||||
pdfcraft_cos::CosError::Filter(why) => why,
|
||||
other => other.to_string(),
|
||||
};
|
||||
unsupported(index, format!("content cannot be decoded strictly: {why}"))
|
||||
}
|
||||
})?;
|
||||
all.extend_from_slice(&decoded);
|
||||
|
||||
@@ -113,7 +113,7 @@ fn autotag_text_reads_content_with_parameters_given_by_reference() {
|
||||
}
|
||||
|
||||
/// Autotagging refuses a page whose content it can't read whole, and says why: content past
|
||||
/// 16 MiB, or content that doesn't decode strictly.
|
||||
/// 16 MiB, or content that doesn't decode strictly, with the decoder's reason right after.
|
||||
#[test]
|
||||
fn autotag_text_says_why_it_cannot_read_a_page() {
|
||||
use pdfcraft_cos::{Dict, ObjRef, Stream};
|
||||
@@ -138,7 +138,7 @@ fn autotag_text_says_why_it_cannot_read_a_page() {
|
||||
let mut corrupt = Stream::from_raw(Dict::new(), b"not zlib data".to_vec());
|
||||
corrupt.dict.set(b"Filter".to_vec(), Object::name("FlateDecode"));
|
||||
let why = reason(corrupt);
|
||||
assert!(why.starts_with("content cannot be decoded strictly"), "{why}");
|
||||
assert!(why.starts_with("content cannot be decoded strictly: FlateDecode: "), "{why}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user