address review: cut only an over-long identifier; test with a filter that can't be read

This commit is contained in:
Dylan M. Taylor committed 2026-11-03 16:03:40 +00:00
1 parent d30582aaa4
commit c7493ff6fe
2 files changed
+5 -5

No files matched your search

+3 -4
View File
@@ -194,12 +194,11 @@ pub fn declared(doc: &Document) -> Declared {
.get(b"OutputConditionIdentifier")
.and_then(|v| {
doc.resolve(v).as_string().map(|s| {
// An even cut keeps UTF-16 text whole code units.
let n = s.bytes.len().min(MAX_IDENTIFIER_BYTES) & !1;
if n == s.bytes.len() {
if s.bytes.len() <= MAX_IDENTIFIER_BYTES {
s.to_text()
} else {
pdfcraft_cos::PdfString { bytes: s.bytes[..n].to_vec(), hex: s.hex }.to_text()
// An even cut keeps UTF-16 text whole code units.
pdfcraft_cos::PdfString { bytes: s.bytes[..MAX_IDENTIFIER_BYTES & !1].to_vec(), hex: s.hex }.to_text()
}
})
})
+2 -1
View File
@@ -541,7 +541,8 @@ fn convert_adds_no_srgb_intent_when_colour_could_not_all_be_read() {
"<< /Type /Catalog /Pages 2 0 R >>",
"<< /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 200 200] >>",
"<< /Type /Page /Parent 2 0 R /Contents 4 0 R /Resources << >> >>",
"<< /Length 9 /Filter /FlateDecode >>\nstream\nnot flate\nendstream",
// A /Filter that isn't a name can't be decoded: the content isn't read.
"<< /Length 9 /Filter 5 >>\nstream\nnot flate\nendstream",
],
"",
);