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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,31 @@ function runTests (solc, versionText) {
}
st.end();
});

t.test('compiling standard JSON (file names containing symbols)', function (st) {
var input = {
'language': 'Solidity',
'settings': {
'outputSelection': {
'*': {
'*': ['evm.bytecode']
}
}
},
'sources': {
'!@#$%^&*()_+-=[]{}\\|"\';:~`<>,.?/': {
'content': 'contract C {}'
}
}
};

var output = JSON.parse(solc.compile(JSON.stringify(input)));
st.ok(expectNoError(output));
var C = getBytecodeStandard(output, '!@#$%^&*()_+-=[]{}\\|"\';:~`<>,.?/', 'C');
st.ok(typeof C === 'string');
st.ok(C.length > 0);
st.end();
});
});
});

Expand Down Expand Up @@ -810,6 +835,7 @@ if (!noRemoteVersions) {
'v0.2.1+commit.91a6b35',
'v0.3.6+commit.3fc68da',
'v0.4.0+commit.acd334c9',
'v0.4.10+commit.f0d539ae',
'v0.4.11+commit.68ef5810',
'v0.4.12+commit.194ff033',
'v0.4.26+commit.4563c3fc'
Expand Down
2 changes: 1 addition & 1 deletion translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

if (tmp.length !== 4) {
// Force abort
return null;
Expand Down