We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Zilliqa::Util::Validator.address? returns false positives for obviously invalid addresses.
Zilliqa::Util::Validator.address?
address = "zil1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Zilliqa::Util::Validator.address?(address)
Expected result: false
Actual result: true
Seems like Zilliqa::Util::Validator.address? uses only regexps to validate the address and doesn't check if the argument is a valid bech32 address.
I found a workaround:
address = "zil1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Zilliqa::Util::Validator.address?(Zilliqa::Util::Bech32.from_bech32(address)) rescue false
this snippet returns false because Zilliqa::Util::Bech32.from_bech32(address) raises an error when invalid address is passed:
Zilliqa::Util::Bech32.from_bech32(address)
2.6.3 :006 > Zilliqa::Util::Bech32.from_bech32(address) Traceback (most recent call last): 2: from (irb):6 1: from (irb):6:in `rescue in irb_binding' NoMethodError (undefined method `[]' for nil:NilClass)
It might make sense to check if the argument of Zilliqa::Util::Validator.address? is a valid bech32 address. WDYT?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Zilliqa::Util::Validator.address?
returns false positives for obviously invalid addresses.Expected result:
false
Actual result:
true
Seems like
Zilliqa::Util::Validator.address?
uses only regexps to validate the address and doesn't check if the argument is a valid bech32 address.I found a workaround:
this snippet returns false because
Zilliqa::Util::Bech32.from_bech32(address)
raises an error when invalid address is passed:It might make sense to check if the argument of
Zilliqa::Util::Validator.address?
is a valid bech32 address. WDYT?The text was updated successfully, but these errors were encountered: