Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panics with invalid date #213

Open
threeseed opened this issue Feb 20, 2024 · 5 comments
Open

Panics with invalid date #213

threeseed opened this issue Feb 20, 2024 · 5 comments

Comments

@threeseed
Copy link

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.

@threeseed
Copy link
Author

Test - Date.pdf

@s3bk
Copy link
Contributor

s3bk commented Feb 20, 2024

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 )`

@yutotakano
Copy link

Just encountered this today. While it's true that it's not standard, it's also rather common in the wild. I checked with bank statement PDFs from four different banks and pdf-rs panicked on the date on every one. Is it out-of-scope of this project to make the parser more lenient? (Generation can be strict to the standard, sure).

@threeseed threeseed reopened this Dec 22, 2024
@threeseed
Copy link
Author

Reviewing this again but it shouldn't be panicking for incorrect dates.

@s3bk
Copy link
Contributor

s3bk commented Dec 22, 2024

@yutotakano You are welcome to make a PR that changes the behavior to a simple String wrapper with a function to try and extract the date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants