aboutsummaryrefslogtreecommitdiff
path: root/js/binary/reader_test.js
diff options
context:
space:
mode:
authorYilun Chong <chongyilun250@sina.com>2018-08-08 11:01:53 -0700
committerGitHub <noreply@github.com>2018-08-08 11:01:53 -0700
commit9bbc4b1fab8262958c172f2d8e87b486c950a051 (patch)
tree20f14bcab01dda31694085060fcfe5bfad34ddcb /js/binary/reader_test.js
parent0483feb6e09895f3c59d4597543ed63d6f05de59 (diff)
parent600e4e5f3b2d1a852a07de61d69e7245b78a5bf3 (diff)
downloadprotobuf-9bbc4b1fab8262958c172f2d8e87b486c950a051.tar.gz
protobuf-9bbc4b1fab8262958c172f2d8e87b486c950a051.tar.bz2
protobuf-9bbc4b1fab8262958c172f2d8e87b486c950a051.zip
Merge pull request #4981 from BSBandme/fix_js_skipgroup
Fix js reader.js's skipGroup
Diffstat (limited to 'js/binary/reader_test.js')
-rw-r--r--js/binary/reader_test.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/js/binary/reader_test.js b/js/binary/reader_test.js
index 95711385..69739727 100644
--- a/js/binary/reader_test.js
+++ b/js/binary/reader_test.js
@@ -679,9 +679,24 @@ describe('binaryReaderTest', function() {
writer.writeInt32(5, sentinel);
var dummyMessage = /** @type {!jspb.BinaryMessage} */({});
writer.writeGroup(5, dummyMessage, function() {
+ // Previously the skipGroup implementation was wrong, which only consume
+ // the decoder by nextField. This case is for making the previous
+ // implementation failed in skipGroup by an early end group tag.
+ // The reason is 44 = 5 * 8 + 4, this will be translated in to a field
+ // with number 5 and with type 4 (end group)
+ writer.writeInt64(44, 44);
+ // This will make previous implementation failed by invalid tag (7).
+ writer.writeInt64(42, 47);
writer.writeInt64(42, 42);
+ // This is for making the previous implementation failed by an invalid
+ // varint. The bytes have at least 9 consecutive minus byte, which will
+ // fail in this.nextField for previous implementation.
+ writer.writeBytes(43, [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]);
writer.writeGroup(6, dummyMessage, function() {
writer.writeInt64(84, 42);
+ writer.writeInt64(84, 44);
+ writer.writeBytes(
+ 43, [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]);
});
});