Vyper: Unicode characters are allowed to be a part of identifiers

Created on 30 Jun 2018  路  2Comments  路  Source: vyperlang/vyper

Version Information

  • vyper Version: Master
  • pyethereum Version: x.x.x
  • OS: osx/linux/win
  • Python Version (python --version):
  • Environment (output of pip freeze):

What's your issue about?

In Vyper, Unicode characters are allowed to be a part of identifiers (variable names, method names, etc.). This could lead to Homograph attacks where a piece of code appears to be acting on one variable but is actually acting on some other variable. Unicode characters should probably be disallowed from being a part of identifiers, especially since Vyper aims to be a language that is easy to audit.


FWIW, Solidity throws an error when I try to name a variable with a unicode character.

Code:

pragma solidity ^0.4.21;

contract Foo {

    function x(int128 i) public view {
        uint256 Other_Balance = 3; // ASCII O

        // a bunch of code
        if (i>0) {
            uint256 袨ther_Balance = 2; // Unicode 袨
        }

        // a bunch of code
        return Other_Balance; // ASCII O
    }
}

Error:

browser/Untitled5.sol:10:21: ParserError: Expected ';' but got 'ILLEGAL'
            uint256 袨ther_Balance = 2; // Unicode 袨
                    ^

Similar code in Vyper, which compiles without throwing any errors:

@public
def fo袨(i: int128) -> uint256:
    Other_Balance: uint256 = 3 # ASCII O

    # a whole bunch of code
    if i > 0:
        袨ther_Balance: uint256 = 2 # Unicode 袨

    # a whole bunch of code

    return Other_Balance # ASCII O

How can it be fixed?

Disallow Unicode characters in identifiers.

Cute Animal Picture

Baby Elephant

bug

All 2 comments

I'd like to work on this if it is something that has to be fixed.

Yes, this is a good issue to work on if you're interested in

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ben-kaufman picture ben-kaufman  路  4Comments

jacqueswww picture jacqueswww  路  4Comments

travs picture travs  路  3Comments

robinsierra picture robinsierra  路  3Comments

lsaether picture lsaether  路  4Comments