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

Reject invalid chunk types #332

Merged
merged 1 commit into from May 6, 2023

Conversation

EvanHahn
Copy link
Contributor

Chunk types must be ASCII letters, according to the PNG spec:

Each byte of a chunk type is restricted to the decimal values 65 to 90 and 97 to 122. These correspond to the uppercase and lowercase ISO 646 letters (A-Z and a-z) respectively...

libpng has a check for this, but pngjs does not before this commit.

This is arguably a breaking change or something you don't want to include, so feel free to reject.

Chunk types must be ASCII letters, [according to the PNG spec][0]:

> Each byte of a chunk type is restricted to the decimal values 65 to 90
> and 97 to 122. These correspond to the uppercase and lowercase ISO 646
> letters (A-Z and a-z) respectively...

[libpng has a check for this][1], but pngjs does not before this commit.

[0]: https://www.w3.org/TR/png/#5Chunk-layout
[1]: https://sourceforge.net/p/libpng/code/ci/e519af8b49f52c4ac400f50f23b48ebe36a5f4df/tree/pngrutil.c#l3145
@codecov
Copy link

codecov bot commented May 6, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.05 🎉

Comparison is base (c836161) 82.52% compared to head (8ae99fd) 82.58%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #332      +/-   ##
==========================================
+ Coverage   82.52%   82.58%   +0.05%     
==========================================
  Files          22       22              
  Lines        1202     1206       +4     
==========================================
+ Hits          992      996       +4     
  Misses        210      210              
Impacted Files Coverage Δ
lib/parser.js 90.56% <100.00%> (+0.24%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lukeapage
Copy link
Collaborator

I think in most cases this results in a better error on a corrupted file so I am in favor and don’t count it as breaking.

@lukeapage lukeapage merged commit 5fc6ebb into pngjs:main May 6, 2023
8 checks passed
@EvanHahn EvanHahn deleted the reject-invalid-chunk-types branch May 6, 2023 10:55
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

Successfully merging this pull request may close these issues.

None yet

2 participants