Skip to content
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

Merged
merged 2 commits into from
Oct 25, 2021

Conversation

cameel
Copy link
Member

@cameel cameel commented Oct 12, 2021

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.

@cameel cameel force-pushed the handle-colons-in-file-names-on-0.4.10 branch from bf9d463 to 7c78d4c Compare October 12, 2021 20:37
@axic
Copy link
Member

axic commented Oct 12, 2021

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(/^((.*):)?([^:]+)$/);
Copy link
Member

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?

Copy link
Member Author

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 86.427% when pulling 7c78d4c on handle-colons-in-file-names-on-0.4.10 into 8920105 on master.

@cameel
Copy link
Member Author

cameel commented Oct 12, 2021

Do you think #242 is related?

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.

@cameel cameel merged commit 55e84db into master Oct 25, 2021
@cameel cameel deleted the handle-colons-in-file-names-on-0.4.10 branch October 25, 2021 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

solc/wrapper crashes on Solidity version 0.4.10 and earlier when there's a colon in the file path
4 participants