Skip to content
This repository was archived by the owner on Aug 23, 2020. It is now read-only.

Commit 926b1f6

Browse files
authored
Merge pull request EOSIO#370 from conr2d/validate-project-name
Throw exception when creating project with invalid identifier
2 parents 8e099ab + fc8f4bd commit 926b1f6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tools/init/eosio-init.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ int main(int argc, const char **argv) {
206206

207207
cl::ParseCommandLineOptions(argc, argv, std::string("eosio-proj"));
208208
try {
209+
if (!std::regex_match(project_name, std::regex("^[_a-zA-Z][_a-zA-Z0-9]*$"))) {
210+
throw std::runtime_error("ERROR: invalid identifier: " + project_name + " (ensure that it is a valid C++ identifier)");
211+
}
209212
llvm::SmallString<128> rp;
210213
std::string path = output_dir;
211214
if (path.empty())

0 commit comments

Comments
 (0)