toUtf8String remove null bytes #3694
-
Ethers Version5.7.2 Search TermstoUtf8String Describe the Problemstring
After toUtf8String = Code Snippetconst b = "0x73756d2d6f662d6e756d62657273000000000000000000000000000000000000";
const mod = ethers.utils.toUtf8String(b);
const ex = await import(mod); Contract ABINo response Errors`TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received '/Users/node_modules/sum-of-numbers\x00\x00\x00\x00\x00\x00\x00\...` Environmentnode.js (v12 or newer) Environment (Other)No response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Your string contains null termination characters. A file name cannot contain either null-termination or slash characters. If you are using a Bytes32 string, you should use the |
Beta Was this translation helpful? Give feedback.
Your string contains null termination characters. A file name cannot contain either null-termination or slash characters.
If you are using a Bytes32 string, you should use the
parseBytes32String
function, which expects a null terminated string. But you should investigate where the source of the string is coming from, because code like that is dangerous and may be subject to arbitrary coded execution or other ACE concerns.