You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have made bad experiences with being loose on hex string prefixes - also on the input side - and allow for lazy input and addition or removal, getting more strict here was therefore a substantial part of one of former breaking release rounds.
The current hexStringToBytes() method does a lazy if (hex.startsWith('0x')) { hex = hex.slice(2) } conversion here.
This leads to the problematic situation that it is just not deterministically decidable if a 0x string is either a prefix or part of the string itself, in case both is allowed.
So let's say one has the - let's assume - prefixed hex string:
0x0x1234
The following would then be the - unprefixed hex string:
0x1234
So it is just not decidable if 0x is part of the string or it is a prefix and it is highly recommendable to request from users to decide on the format before-hand. The prefixed version is preferred here since once can always throw if a non-prefixed version is provided, and so do an always-working format check.
This is not only a theoretical example. People can put arbitrary byte data on some fields (e.g. extraData) or might even do this on purpose 😋 to annoy developers and cause things to break.
So, long story short: we should definitely update here before the breaking releases and rename to prefixedHexStringToBytes(), remove the 0x stripping and throw for all non-0x-strings passed.
I will already add/reference the updated name to the release notes.
The text was updated successfully, but these errors were encountered:
We have made bad experiences with being loose on hex string prefixes - also on the input side - and allow for lazy input and addition or removal, getting more strict here was therefore a substantial part of one of former breaking release rounds.
The current
hexStringToBytes()
method does a lazyif (hex.startsWith('0x')) { hex = hex.slice(2) }
conversion here.This leads to the problematic situation that it is just not deterministically decidable if a
0x
string is either a prefix or part of the string itself, in case both is allowed.So let's say one has the - let's assume - prefixed hex string:
The following would then be the - unprefixed hex string:
0x1234
So it is just not decidable if
0x
is part of the string or it is a prefix and it is highly recommendable to request from users to decide on the format before-hand. The prefixed version is preferred here since once can always throw if a non-prefixed version is provided, and so do an always-working format check.This is not only a theoretical example. People can put arbitrary byte data on some fields (e.g.
extraData
) or might even do this on purpose 😋 to annoy developers and cause things to break.So, long story short: we should definitely update here before the breaking releases and rename to
prefixedHexStringToBytes()
, remove the0x
stripping and throw for all non-0x-strings passed.I will already add/reference the updated name to the release notes.
The text was updated successfully, but these errors were encountered: