Skip to content

Commit

Permalink
Verify empty base64 encoded strings for bytes fields, see #535
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Dec 10, 2016
1 parent a0398f5 commit 67449db
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions dist/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/codegen/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function verifyValue(field, value) {
return invalid(field, "string");
break;
case "bytes":
if (!(value && typeof value.length === 'number'))
if (!(value && typeof value.length === 'number' || util.isString(value)))
return invalid(field, "buffer");
break;
default:
Expand Down Expand Up @@ -187,7 +187,7 @@ function genVerifyValue(gen, field, fieldIndex, ref) {
("return%j", invalid(field, "string"));
break;
case "bytes": gen
("if(!(%s&&typeof %s.length==='number'))", ref, ref)
("if(!(%s&&typeof %s.length==='number'||util.isString(%s))", ref, ref, ref)
("return%j", invalid(field, "buffer"));
break;
default:
Expand Down

0 comments on commit 67449db

Please sign in to comment.