Skip to content

Commit

Permalink
Handle edge case when parsing (#1826)
Browse files Browse the repository at this point in the history
* Change configuration

* Downgrade solcx

* Handle edge case when parsing
  • Loading branch information
norhh authored Dec 13, 2023
1 parent 460e9da commit 2bf6a35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mythril/ethereum/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def parse_pragma(solidity_code):
max_version = Optional(inequality + version)
pragma = Word("pragma") + Word("solidity") + min_version + Optional(max_version)
result = pragma.parseString(solidity_code)
min_inequality = result[2] if result[2] in [">", "<", ">=", "<="] else ""
min_inequality = result[2] if result[2] in [">", "<", ">=", "<=", "="] else ""
min_carrot = result[2] if result[2] == "^" else ""
min_version = result[3] if min_carrot != "" or min_inequality != "" else result[2]
return {
Expand Down
1 change: 1 addition & 0 deletions tests/util_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

test_data = (
("pragma solidity 0.5.0\n", ["0.5.0"]),
("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)]),
Expand Down

0 comments on commit 2bf6a35

Please sign in to comment.