Skip to content

Commit 06de89a

Browse files
authored
Merge pull request ethereum#1648 from ethereum/escape-filenames
Always escape filenames in solc
2 parents 46b2d52 + 4641247 commit 06de89a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Features:
44
* Type system: Support explicit conversion of external function to address.
55

66
Bugfixes:
7+
* Commandline interface: Always escape filenames (replace ``/``, ``:`` and ``.`` with ``_``).
78
* Type system: Disallow arrays with negative length.
89

910
### 0.4.9 (2017-01-31)

solc/CommandLineInterface.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void CommandLineInterface::handleBinary(string const& _contract)
200200
if (m_args.count(g_argCloneBinary))
201201
{
202202
if (m_args.count(g_argOutputDir))
203-
createFile(_contract + ".clone_bin", m_compiler->cloneObject(_contract).toHex());
203+
createFile(m_compiler->filesystemFriendlyName(_contract) + ".clone_bin", m_compiler->cloneObject(_contract).toHex());
204204
else
205205
{
206206
cout << "Clone Binary: " << endl;
@@ -210,7 +210,7 @@ void CommandLineInterface::handleBinary(string const& _contract)
210210
if (m_args.count(g_argBinaryRuntime))
211211
{
212212
if (m_args.count(g_argOutputDir))
213-
createFile(_contract + ".bin-runtime", m_compiler->runtimeObject(_contract).toHex());
213+
createFile(m_compiler->filesystemFriendlyName(_contract) + ".bin-runtime", m_compiler->runtimeObject(_contract).toHex());
214214
else
215215
{
216216
cout << "Binary of the runtime part: " << endl;
@@ -222,7 +222,7 @@ void CommandLineInterface::handleBinary(string const& _contract)
222222
void CommandLineInterface::handleOpcode(string const& _contract)
223223
{
224224
if (m_args.count(g_argOutputDir))
225-
createFile(_contract + ".opcode", solidity::disassemble(m_compiler->object(_contract).bytecode));
225+
createFile(m_compiler->filesystemFriendlyName(_contract) + ".opcode", solidity::disassemble(m_compiler->object(_contract).bytecode));
226226
else
227227
{
228228
cout << "Opcodes: " << endl;
@@ -249,7 +249,7 @@ void CommandLineInterface::handleSignatureHashes(string const& _contract)
249249
out += toHex(it.first.ref()) + ": " + it.second->externalSignature() + "\n";
250250

251251
if (m_args.count(g_argOutputDir))
252-
createFile(_contract + ".signatures", out);
252+
createFile(m_compiler->filesystemFriendlyName(_contract) + ".signatures", out);
253253
else
254254
cout << "Function signatures: " << endl << out;
255255
}
@@ -261,7 +261,7 @@ void CommandLineInterface::handleOnChainMetadata(string const& _contract)
261261

262262
string data = m_compiler->onChainMetadata(_contract);
263263
if (m_args.count("output-dir"))
264-
createFile(_contract + "_meta.json", data);
264+
createFile(m_compiler->filesystemFriendlyName(_contract) + "_meta.json", data);
265265
else
266266
cout << "Metadata: " << endl << data << endl;
267267
}
@@ -302,7 +302,7 @@ void CommandLineInterface::handleMeta(DocumentationType _type, string const& _co
302302
output = dev::jsonPrettyPrint(m_compiler->metadata(_contract, _type));
303303

304304
if (m_args.count(g_argOutputDir))
305-
createFile(_contract + suffix, output);
305+
createFile(m_compiler->filesystemFriendlyName(_contract) + suffix, output);
306306
else
307307
{
308308
cout << title << endl;
@@ -981,7 +981,7 @@ void CommandLineInterface::outputCompilationResults()
981981
{
982982
stringstream data;
983983
m_compiler->streamAssembly(data, contract, m_sourceCodes, m_args.count(g_argAsmJson));
984-
createFile(contract + (m_args.count(g_argAsmJson) ? "_evm.json" : ".evm"), data.str());
984+
createFile(m_compiler->filesystemFriendlyName(contract) + (m_args.count(g_argAsmJson) ? "_evm.json" : ".evm"), data.str());
985985
}
986986
else
987987
{

0 commit comments

Comments
 (0)