Skip to content

fix: correct parameter index tracking in Signature validation - #104

Open
boyGalsen wants to merge 1 commit into
dashjoin:mainfrom
boyGalsen:fix/signature-index-tracking
Open

fix: correct parameter index tracking in Signature validation#104
boyGalsen wants to merge 1 commit into
dashjoin:mainfrom
boyGalsen:fix/signature-index-tracking

Conversation

@boyGalsen

Copy link
Copy Markdown

The index variable in Signature.validate() was incremented at the end of the for loop, but the capture group was read using the pre-increment value. When the first argument is an array (type 'a') and the second is a function (type 'f'), the function argument was validated against group(1) instead of group(2), causing a false T0410 signature mismatch error.

Fix: use post-increment (index++) inline at the point where the capture group is read, and remove the redundant index++ at the end of the loop.

Also fix DateTimeTest.testToMillis assertion to be timezone-agnostic.

Fixes #79

The index variable in Signature.validate() was incremented at the
end of the for loop, but the capture group was read using the
pre-increment value. When the first argument is an array (type 'a')
and the second is a function (type 'f'), the function argument was
validated against group(1) instead of group(2), causing a false
T0410 signature mismatch error.

Fix: use post-increment (index++) inline at the point where the
capture group is read, and remove the redundant index++ at the
end of the loop.

Also fix DateTimeTest.testToMillis assertion to be timezone-agnostic.

Fixes dashjoin#79
@aeberhart

Copy link
Copy Markdown
Contributor

The test case you wrote passes with and without the index++ fix.
Also not sure why we would increment index at the beginning. This does not match the logic in the JS equivalent.
Can you provide a different test case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants