moov-io / iso8583

A golang implementation to marshal and unmarshal iso8583 message.
https://moov.io
Apache License 2.0
306 stars 100 forks source link

Fix variable length HEX prefix #193

Closed svz-ya closed 1 year ago

svz-ya commented 1 year ago

I believe that variable length HEX prefix is encoded/decoded incorrectly. For example, if we have a data block with length 24 bytes and encode prefix.Hex.LLL prefix it gives:

+ 00000000  33 32 33 34                                       |3234|

i.e. ASCII-HEX representation of decimal number 24 without even a padding to 3 digits. However it is expected to have

- 00000000  30 30 30 30 31 38                                 |000018|

ASCII representation of 0x000018. LLL means 3 bytes for hex number, which is 6 hex nibbles.

alovak commented 1 year ago

@svz-ya I think that you are right. Unfortunately there are no tests for the hex prefixes. We should be careful with not breaking what may for others (even if we now see it's not how it should work 🙈)

svz-ya commented 1 year ago

@alovak

We should be careful with not breaking what may for others (even if we now see it's not how it should work see_no_evil)

I agree. So what are your suggestions?

alovak commented 1 year ago

@svz-ya please, rebase, and we will merge it :)

alovak commented 1 year ago

@svz-ya I've rebased and merged it myself here: https://github.com/moov-io/iso8583/pull/198

thank you for your contribution!

alovak commented 1 year ago

it was released https://github.com/moov-io/iso8583/releases/tag/v0.12.2 @svz-ya