-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash on 0.4.10 when the file name contains a colon #556
Conversation
…ompiler output from 0.4.10
….11-0.4.19 in tests
bf9d463
to
7c78d4c
Compare
Do you think #242 is related? |
@@ -78,7 +78,7 @@ function translateJsonCompilerOutput (output, libraries) { | |||
ret['contracts'] = {}; | |||
for (var contract in output['contracts']) { | |||
// Split name first, can be `contract`, `:contract` or `filename:contract` | |||
var tmp = contract.match(/^(([^:]*):)?([^:]+)$/); | |||
var tmp = contract.match(/^((.*):)?([^:]+)$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the change is to find the last colon, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. The assumption is that the contract name itself can never contain a colon so the last one must be the one separating it from the file name.
Well, it's the same kind of issue but in a different situation (input rather than output). We could finish that PR but we should reproduce it first - it does not link to an issue and there's no failing test case there so hard to say if the issue is real and which versions it affects. |
Fixes #555.
We provide output translation on older versions (<= 0.4.10) that did not support Standard JSON. The translation uses a regex that assumes that the file name never contains a colon. On <= 0.4.9 the name is empty so it's ok but on 0.4.10 this causes a crash when compiling contracts with a colon in the file name.
Also, it looks like the
contracts
dict in standard JSON had incorrectly split names until 0.4.20. On 0.4.11-0.4.19 apparently the compiler joins the file name and contract name into<filename>:<contractName>
and then (incorrectly) splits it again on the first colon. This results in a wrong split when there are multiple colons in the file name. This PR fixes tests to be able to handle that. It would probably be better to make this fix on a deeper level and make solc-js return correct Standard JSON for users too.