pdf-rs / pdf

Rust library to read, manipulate and write PDF files.
MIT License
1.29k stars 120 forks source link

Panics with invalid date #213

Closed nadenf closed 8 months ago

nadenf commented 8 months ago

Attached is a reproducible test case with it panicking within the following method:

impl Object for Date {
    fn from_primitive(p: Primitive, r: &impl Resolve) -> Result<Self> {}
}

With the following date:

2/10/2024 19:54:36

Ideally it shouldn't bail if there is an invalid date but maybe render a blank string.

nadenf commented 8 months ago

Test - Date.pdf

s3bk commented 8 months ago

It returns an Error which is correct, because this is not a valid PDF file.

2/10/2024 19:54:36 is not a valid date. Check 7.9.4 of PDF32000.

Date values used in a PDF shall conform to a standard date format, which closely follows that of the international standard ASN.1 (Abstract Syntax Notation One), defined in ISO/IEC 8824. A date shall be a text string of the form ( D : YYYYMMDDHHmmSSOHH ' mm )`