-
Notifications
You must be signed in to change notification settings - Fork 687
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
Wrong gradient attributes occasionally being rendered #1048
Comments
I have similar problem. Suggested solution from @jacksop works for me. |
@jacksop Thank you for reporting this. Sorry for the delay. I’m a bit busy right now. A quick check in the code indeed reveals shortcomings of key construction. Hashing function is OK. We don’t really need longer keys. The flaw is in the As I mentioned, I’m a bit busy right now so I wouldn’t be able to fix this fast. I’d gladly accept a PR though. So if you wish to work on this feel free to take it. I can help with an advice. |
Thanks @pointlessone. I'll put together a PR. |
@pointlessone Do I need specific access in order to push a branch? |
@jacksop Yes. Try submitting a PR from your fork. |
Packing gradient attributes down to 8-bit values causes collisions when generating the SHA1 digest. Concatinate the gradient attributes into a string in order to calculate the digest for the key.
I have a document with several small polygon shapes in different colours over many pages. I am experiencing an issue where occasionally a shape is rendered in the wrong colour.
I believe this is caused by collisions in the registry key used to store the gradient as a page resource. The key is created from a digest of the gradient attributes, packed as unsigned 8-bit characters.
Example
This small example illustrates the issue.
The key for the gradient on the bottom right is identical to the previously generated key for the top right gradient and consequently the rectangle uses the old gradient definition.
Solution
Would it be possible to avoid packing the attributes down to 8-bit values and to also use a SHA2 digest (for a longer key)?
Suggest changing the method in lib/prawn/graphics/patterns.rb from:
to:
The text was updated successfully, but these errors were encountered: