From 80c3469a917e9919968abad87ae19ea312456dd8 Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Wed, 13 Dec 2023 15:43:05 +0000 Subject: [PATCH] Handle edge case when parsing --- mythril/ethereum/util.py | 2 +- tests/util_tests.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mythril/ethereum/util.py b/mythril/ethereum/util.py index 76017951..f5d0383b 100644 --- a/mythril/ethereum/util.py +++ b/mythril/ethereum/util.py @@ -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 { diff --git a/tests/util_tests.py b/tests/util_tests.py index 59366ca9..06fdea89 100644 --- a/tests/util_tests.py +++ b/tests/util_tests.py @@ -5,6 +5,7 @@ from mythril.ethereum.util import extract_version 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)]),