@@ -37,6 +37,24 @@ contract zkPhoto is ERC721 {
3737 verifierAddr = _verifier;
3838 }
3939
40+ /**
41+ * @dev check invalid characters in input string
42+ * @param String input string to be checked
43+ */
44+ function HasQuotationMark (
45+ string calldata String
46+ ) private pure returns (bool ) {
47+ bytes calldata StringBytes = bytes (String);
48+ bytes1 quote = bytes1 ("\" " );
49+ uint256 length = StringBytes.length ;
50+ for (uint256 i = 0 ; i < length; ++ i) {
51+ if (StringBytes[i]== quote) {
52+ return true ;
53+ }
54+ }
55+ return false ;
56+ }
57+
4058 /**
4159 * @dev generateTokenURI based on input
4260 * @param name name in tokenURI
@@ -93,19 +111,21 @@ contract zkPhoto is ERC721 {
93111 uint256 [2 ][16 ] calldata c ,
94112 uint256 [65 ][16 ] calldata input
95113 ) public returns (uint256 ) {
114+ require (! HasQuotationMark (name) && ! HasQuotationMark (description) && ! HasQuotationMark (image), "Invalid metadata " );
115+
96116 bytes32 _hash = generateHash (input);
97117
98118 require (! hashExists[_hash], "Image already exists " );
99119
100- for (uint256 i = 0 ; i < 16 ; i ++ ) {
120+ for (uint256 i = 0 ; i < 16 ; ++ i ) {
101121 uint256 [2 ] memory _a = [a[i][0 ], a[i][1 ]];
102122 uint256 [2 ][2 ] memory _b = [
103123 [b[i][0 ][0 ], b[i][0 ][1 ]],
104124 [b[i][1 ][0 ], b[i][1 ][1 ]]
105125 ];
106126 uint256 [2 ] memory _c = [c[i][0 ], c[i][1 ]];
107127 uint256 [65 ] memory _input;
108- for (uint256 j = 0 ; j < 65 ; j ++ ) {
128+ for (uint256 j = 0 ; j < 65 ; ++ j ) {
109129 _input[j] = input[i][j];
110130 }
111131 require (
0 commit comments