Skip to content

normalizeIotaAddress() doesn't handle invalid inputs #5768

@Thoralf-M

Description

@Thoralf-M

Bug description

If one provides an invalid input to normalizeIotaAddress() it will not return an error, but an invalid string which is not a valid address

Steps To reproduce the bug

import { normalizeIotaAddress } from '@iota/iota-sdk/utils';
// Doesn't care if it's invalid hex chars
console.log(normalizeIotaAddress(" xyz"))
// Empty space isn't checked
console.log(normalizeIotaAddress(" 0xf60e1cb99687c246c307b637bee7fb5e25b5164c250c628cce83df03b32cbd1a"))

prints

0x000000000000000000000000000000000000000000000000000000000000 xyz
0x 0xf60e1cb99687c246c307b637bee7fb5e25b5164c250c628cce83df03b32cbd1a

Expected behaviour

Should return an error

Actual behaviour

Returns strings that aren't valid addresses

Metadata

Metadata

Labels

toolingIssues related to the Tooling teamts-sdkIssues related to the TS SDK

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions