Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Correctly decode UTF-8 #2129

Merged
merged 1 commit into from Jun 25, 2019
Merged

Correctly decode UTF-8 #2129

merged 1 commit into from Jun 25, 2019

Conversation

haltman-at
Copy link
Contributor

I originally made this change on type-and-value, then realized it was worth backporting to develop. (I'm setting myself up for a merge conflict, but...)

This PR fixes an issue in string decoding by using the utf8 library to convert Solidity's UTF-8 to Javascript's UTF-16. Note that Solidity does allow malformed UTF-8; in this case, we simply return null. (Note that we detect this case by seeing whether utf8.decode throws an error; it doesn't seem to have a check function separate from the decode.)

Why null rather than undefined? To avoid throwing the debugger into an infinite loop in case a mapping key is a malformed string. Yes, this is a bit of a hack, but don't worry, it'll be gone in 5.1; on type-and-value we return an object representing the particular malformed string rather than a simple null. But here on develop, without the new output format, null will have to suffice.

@haltman-at haltman-at requested a review from gnidan June 25, 2019 05:40
@coveralls
Copy link

Coverage Status

Coverage remained the same at 70.16% when pulling cf26256 on utf8-develop into 5071514 on develop.

@haltman-at haltman-at merged commit ddc5216 into develop Jun 25, 2019
@haltman-at haltman-at deleted the utf8-develop branch June 25, 2019 18:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants