Skip to content

Byte.parseHex(String str) could throw IllegalArgumentException #37

Description

@petrukhnov

Byte.parseHex(String str) could throw IllegalArgumentException on malformed string. It is not mentioned in docs or javadoc.

java.lang.IllegalArgumentException: invalid hex string, must be mod 2 == 0
	at at.favre.lib.bytes.BinaryToTextEncoding$Hex.decode(BinaryToTextEncoding.java:108)
	at at.favre.lib.bytes.Bytes.parse(Bytes.java:652)
	at at.favre.lib.bytes.Bytes.parseHex(Bytes.java:603)


Activity

  1. patrickfav commented on May 10, 2019

    @patrickfav
    Owner

    Thanks for reporting, I will add a hint in the javadoc

  2. patrickfav commented on May 23, 2019

    @patrickfav
    Owner

    On a different thought, since the decoder is very forgiving, I added the feature that it also accepts odd number length strings with auto padding of zero, so currently (ie. next release 1.2.0) it supports:

    • Upper- and lowercase a-f (also mixed case)
    • Prefix with 0x which will be ignored
    • Even and odd number of string length with auto zero padding (ie. 'E3F' is same as '0E3F')
  3. added this to the v1.2.0 milestone on May 23, 2019
  4. self-assigned this
    on May 23, 2019
  5. patrickfav commented on May 23, 2019

    @patrickfav
    Owner

    Will be released with 1.2.0

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

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions