diff --git a/mythril/ethereum/util.py b/mythril/ethereum/util.py index 08d6927f..51907b89 100644 --- a/mythril/ethereum/util.py +++ b/mythril/ethereum/util.py @@ -141,7 +141,7 @@ def extract_version(file: str) -> Optional[str]: for line in file.split("\n"): if "pragma solidity" not in line: continue - version_line = line + version_line = line.rstrip() break if version_line is None: return None diff --git a/tests/util_tests.py b/tests/util_tests.py index 6fa5a1d9..6928c8f7 100644 --- a/tests/util_tests.py +++ b/tests/util_tests.py @@ -7,8 +7,17 @@ test_data = ( ("pragma solidity 0.5.0\n", ["0.5.0"]), ("pragma solidity ^0.4.26\n", ["0.4.26"]), ("pragma solidity ^0.6.3;\n", [f"0.6.{x}" for x in range(3, 13)]), + ("pragma solidity ^0.6.3 ;\n", [f"0.6.{x}" for x in range(3, 13)]), ( - """pragma solidity >=0.4.0 <0.6.0; + "pragma solidity ^0.6.3; \n", + [f"0.6.{x}" for x in range(3, 13)], + ), + ( + "pragma solidity ^0.6.3 ; \n", + [f"0.6.{x}" for x in range(3, 13)], + ), + ( + """pragma solidity >=0.4.0 <0.6.0 ; contract SimpleStorage { uint storedData; function set(uint x) public {