Skip to content

Commit

Permalink
add format check for contract version
Browse files Browse the repository at this point in the history
  • Loading branch information
fqliao committed Apr 2, 2019
1 parent 2b6e121 commit 0858a99
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/console/ConsoleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,11 @@ public void deployByCNS(String[] params) throws Exception {
System.out.println();
return;
}
if (!contractVersion.matches("^[A-Za-z0-9.]+$")) {
System.out.println("Contract version should only contains 'A-Z' or 'a-z' or '0-9' or dot mark.");
System.out.println();
return;
}
try {
Contract contract = (Contract) remoteCall.send();
contractAddress = contract.getContractAddress();
Expand Down Expand Up @@ -1267,6 +1272,11 @@ public void callByCNS(String[] params) throws Exception {
System.out.println();
return;
}
if (!contractVersion.matches("^[A-Za-z0-9.]+$")) {
System.out.println("Contract version should only contains 'A-Z' or 'a-z' or '0-9' or dot mark.");
System.out.println();
return;
}
CnsService cnsResolver = new CnsService(web3j, credentials);
try {
contractAddress =
Expand Down Expand Up @@ -1362,6 +1372,11 @@ public void queryCNS(String[] params) throws Exception {
System.out.println();
return;
}
if (!contractVersion.matches("^[A-Za-z0-9.]+$")) {
System.out.println("Contract version should only contains 'A-Z' or 'a-z' or '0-9' or dot mark.");
System.out.println();
return;
}
cnsInfos = cnsService.queryCnsByNameAndVersion(contractName, contractVersion);
} else {
cnsInfos = cnsService.queryCnsByName(contractName);
Expand Down

0 comments on commit 0858a99

Please sign in to comment.