-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Fix TypeError that occurs in colorspace.js on accidentally passing an 'Array' instead of 'TypedArray' #8666
Conversation
/botio-linux preview |
Thanks for the patch, but I've got a couple of questions/suggestions below. Did you successfully run the reference tests locally, as explained in https://github.com/mozilla/pdf.js/wiki/Contributing, with this patch? From looking at the history of the code, see PR #3334, it appears that the only reason for supporting } else if (lookup instanceof Uint8Array) {
this.lookup = lookup;
} else if (lookup instanceof Array) {
this.lookup = new Uint8Array(lookup); Also, please update the commit message (and PR title) to something a little more descriptive, since it's really impossible to tell what the patch does based on |
Hi @Snuffleupagus , there is one more issue with making it as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you need to change getRgbItem -> getRgbBuffer call in the IndexedCS_getRgbItem above.
94895e7
to
d8e5577
Compare
src/core/colorspace.js
Outdated
this.lookup = lookup; | ||
} else if (lookup instanceof Array) { | ||
this.lookup = new Uint8Array(lookup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert the changes above? For IE9, it will not matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good (with just getRgbBuffer change)
4a5b49d
to
7068c9b
Compare
/botio test |
… 'Array' instead of 'TypedArray' Fix TypeError that occurs in colorspace.js on accidentally passing an 'Array' instead of 'TypedArray' Changed getRgbItem(...) to getRgbBuffer(...) since this.lookup has values in range[0, 255] whereas getRgbItem(...) expects those to be in range [0, 1] Revert changes for IE9 compatibility
7068c9b
to
d14956d
Compare
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/8b8ec0b4975c7dc/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/8b8ec0b4975c7dc/output.txt Total script time: 2.38 mins Published |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 2 Live output at: http://54.215.176.217:8877/cef1bb0b5ee49e7/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/f003bbfb52e8025/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/f003bbfb52e8025/output.txt Total script time: 16.58 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/cef1bb0b5ee49e7/output.txt Total script time: 29.34 mins
|
Merging with r=yurydelendik. Thank you for the patch! |
Added unit-tests for DeviceGray, DeviceRGB and DeviceCMYK Added unit-tests for CalGray Added unit-tests for CalRGB Removed redundant code Added unit-tests for LabCS Added unit-tests for IndexedCS Update comment Change lookup to Uint8Array as mentioned in pdf specs(these tests will pass after PR mozilla#8666 is merged). Added unit-tests for AlternateCS
Added unit-tests for DeviceGray, DeviceRGB and DeviceCMYK Added unit-tests for CalGray Added unit-tests for CalRGB Removed redundant code Added unit-tests for LabCS Added unit-tests for IndexedCS Update comment Change lookup to Uint8Array as mentioned in pdf specs(these tests will pass after PR mozilla#8666 is merged). Added unit-tests for AlternateCS Resolved code-style issues
Added unit-tests for DeviceGray, DeviceRGB and DeviceCMYK Added unit-tests for CalGray Added unit-tests for CalRGB Removed redundant code Added unit-tests for LabCS Added unit-tests for IndexedCS Update comment Change lookup to Uint8Array as mentioned in pdf specs(these tests will pass after PR mozilla#8666 is merged). Added unit-tests for AlternateCS Resolved code-style issues Fixed code-style issues
Added unit-tests for DeviceGray, DeviceRGB and DeviceCMYK Added unit-tests for CalGray Added unit-tests for CalRGB Removed redundant code Added unit-tests for LabCS Added unit-tests for IndexedCS Update comment Change lookup to Uint8Array as mentioned in pdf specs(these tests will pass after PR mozilla#8666 is merged). Added unit-tests for AlternateCS Resolved code-style issues Fixed code-style issues Addressed issues pointed out in mozilla#8611 (review)
Fix TypeError that occurs in colorspace.js on accidentally passing an 'Array' instead of 'TypedArray'
Added unit-tests for DeviceGray, DeviceRGB and DeviceCMYK Added unit-tests for CalGray Added unit-tests for CalRGB Removed redundant code Added unit-tests for LabCS Added unit-tests for IndexedCS Update comment Change lookup to Uint8Array as mentioned in pdf specs(these tests will pass after PR mozilla#8666 is merged). Added unit-tests for AlternateCS Resolved code-style issues Fixed code-style issues Addressed issues pointed out in mozilla#8611 (review)
Hi,
(Assumption: The base color space is set to be DeviceRGB)
If an
Array
(not asTypedArray
orString
) is passed inIndexedCS
constructor(https://github.com/mozilla/pdf.js/blob/master/src/core/colorspace.js#L509) aslookup
, TypeError occurs on callingfillRgb(...)
(onIndexedCS
object), passinglookup
ascomps
(https://github.com/mozilla/pdf.js/blob/master/src/core/colorspace.js#L116-L118). The error occurs because ofsrc.subarray(...)
in https://github.com/mozilla/pdf.js/blob/master/src/core/colorspace.js#L635 sincesrc
is expected to be aTypedArray
. I made a small change to fix this.