Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
8741da3e
Commit
8741da3e
authored
Sep 13, 2017
by
Paul Yang
Committed by
GitHub
Sep 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix js conformance tests. (#3604)" (#3633)
This reverts commit
2bd55a9f
.
parent
2bd55a9f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
44 deletions
+93
-44
failure_list_js.txt
conformance/failure_list_js.txt
+19
-0
decoder.js
js/binary/decoder.js
+15
-12
decoder_test.js
js/binary/decoder_test.js
+18
-1
decoder_test.js
js/compatibility_tests/v3.0.0/binary/decoder_test.js
+18
-1
decoder_test.js
js/compatibility_tests/v3.1.0/binary/decoder_test.js
+18
-1
js_generator.cc
src/google/protobuf/compiler/js/js_generator.cc
+5
-29
No files found.
conformance/failure_list_js.txt
View file @
8741da3e
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
js/binary/decoder.js
View file @
8741da3e
...
...
@@ -582,24 +582,27 @@ jspb.BinaryDecoder.prototype.readUnsignedVarint32 = function() {
x
|=
(
temp
&
0x0F
)
<<
28
;
if
(
temp
<
128
)
{
// We're reading the high bits of an unsigned varint. The byte we just read
// also contains bits 33 through 35, which we're going to discard.
// also contains bits 33 through 35, which we're going to discard. Those
// bits _must_ be zero, or the encoding is invalid.
goog
.
asserts
.
assert
((
temp
&
0xF0
)
==
0
);
this
.
cursor_
+=
5
;
goog
.
asserts
.
assert
(
this
.
cursor_
<=
this
.
end_
);
return
x
>>>
0
;
}
// If we get here, we need to truncate coming bytes. However we need to make
// sure cursor place is correct.
var
i
=
5
;
do
{
goog
.
asserts
.
assert
(
i
<
10
);
if
(
bytes
[
this
.
cursor_
+
i
]
<
128
)
{
break
;
}
i
++
;
}
while
(
1
);
// If we get here, we're reading the sign extension of a negative 32-bit int.
// We can skip these bytes, as we know in advance that they have to be all
// 1's if the varint is correctly encoded. Since we also know the value is
// negative, we don't have to coerce it to unsigned before we return it.
goog
.
asserts
.
assert
((
temp
&
0xF0
)
==
0xF0
);
goog
.
asserts
.
assert
(
bytes
[
this
.
cursor_
+
5
]
==
0xFF
);
goog
.
asserts
.
assert
(
bytes
[
this
.
cursor_
+
6
]
==
0xFF
);
goog
.
asserts
.
assert
(
bytes
[
this
.
cursor_
+
7
]
==
0xFF
);
goog
.
asserts
.
assert
(
bytes
[
this
.
cursor_
+
8
]
==
0xFF
);
goog
.
asserts
.
assert
(
bytes
[
this
.
cursor_
+
9
]
==
0x01
);
this
.
cursor_
+=
i
+
1
;
this
.
cursor_
+=
10
;
goog
.
asserts
.
assert
(
this
.
cursor_
<=
this
.
end_
);
return
x
;
};
...
...
js/binary/decoder_test.js
View file @
8741da3e
...
...
@@ -270,7 +270,24 @@ describe('binaryDecoderTest', function() {
assertThrows
(
function
()
{
decoder
.
readSignedVarint64
()});
decoder
.
reset
();
assertThrows
(
function
()
{
decoder
.
readZigzagVarint64
()});
decoder
.
reset
();
// Positive 32-bit varints encoded with 1 bits in positions 33 through 35
// should trigger assertions.
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x1F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x2F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x4F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
// Negative 32-bit varints encoded with non-1 bits in the high dword should
// trigger assertions.
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
255
,
255
,
0
,
255
,
255
,
1
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
0
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
});
...
...
js/compatibility_tests/v3.0.0/binary/decoder_test.js
View file @
8741da3e
...
...
@@ -228,7 +228,24 @@ describe('binaryDecoderTest', function() {
assertThrows
(
function
()
{
decoder
.
readSignedVarint64
()});
decoder
.
reset
();
assertThrows
(
function
()
{
decoder
.
readZigzagVarint64
()});
decoder
.
reset
();
// Positive 32-bit varints encoded with 1 bits in positions 33 through 35
// should trigger assertions.
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x1F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x2F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x4F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
// Negative 32-bit varints encoded with non-1 bits in the high dword should
// trigger assertions.
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
255
,
255
,
0
,
255
,
255
,
1
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
0
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
});
...
...
js/compatibility_tests/v3.1.0/binary/decoder_test.js
View file @
8741da3e
...
...
@@ -228,7 +228,24 @@ describe('binaryDecoderTest', function() {
assertThrows
(
function
()
{
decoder
.
readSignedVarint64
()});
decoder
.
reset
();
assertThrows
(
function
()
{
decoder
.
readZigzagVarint64
()});
decoder
.
reset
();
// Positive 32-bit varints encoded with 1 bits in positions 33 through 35
// should trigger assertions.
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x1F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x2F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
0x4F
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
// Negative 32-bit varints encoded with non-1 bits in the high dword should
// trigger assertions.
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
255
,
255
,
0
,
255
,
255
,
1
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
decoder
.
setBlock
([
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
255
,
0
]);
assertThrows
(
function
()
{
decoder
.
readUnsignedVarint32
()});
});
...
...
src/google/protobuf/compiler/js/js_generator.cc
View file @
8741da3e
...
...
@@ -2876,29 +2876,6 @@ void Generator::GenerateClassDeserializeBinaryField(
"Group"
:
"Message"
,
"grpfield"
,
(
field
->
type
()
==
FieldDescriptor
::
TYPE_GROUP
)
?
(
SimpleItoa
(
field
->
number
())
+
", "
)
:
""
);
}
else
if
(
field
->
is_repeated
()
&&
field
->
cpp_type
()
!=
FieldDescriptor
::
CPPTYPE_STRING
)
{
printer
->
Print
(
" if (reader.getWireType() == 2) {
\n
"
" var value = /** @type {$fieldtype_packed$} */ "
"(reader.readPacked$reader$());
\n
"
" msg.set$list_name$(value);
\n
"
" } else {
\n
"
" var value = /** @type {$fieldtype$} */ "
"(reader.read$reader$());
\n
"
" msg.add$name$(value);
\n
"
" }
\n
"
,
"fieldtype_packed"
,
JSFieldTypeAnnotation
(
options
,
field
,
false
,
true
,
/* singular_if_not_packed */
false
,
BYTES_U8
),
"fieldtype"
,
JSFieldTypeAnnotation
(
options
,
field
,
false
,
true
,
/* singular_if_not_packed */
true
,
BYTES_U8
),
"reader"
,
JSBinaryReaderMethodType
(
field
),
"list_name"
,
JSGetterName
(
options
,
field
),
"name"
,
JSGetterName
(
options
,
field
,
BYTES_DEFAULT
,
/* drop_list = */
true
)
);
}
else
{
printer
->
Print
(
" var value = /** @type {$fieldtype$} */ "
...
...
@@ -2910,15 +2887,14 @@ void Generator::GenerateClassDeserializeBinaryField(
JSBinaryReadWriteMethodName
(
field
,
/* is_writer = */
false
));
}
if
(
field
->
is_repeated
()
&&
(
field
->
cpp_type
()
==
FieldDescriptor
::
CPPTYPE_MESSAGE
||
field
->
cpp_type
()
==
FieldDescriptor
::
CPPTYPE_STRING
))
{
if
(
field
->
is_repeated
()
&&
!
field
->
is_packed
())
{
printer
->
Print
(
" msg.add$name$(value);
\n
"
,
"name"
,
JSGetterName
(
options
,
field
,
BYTES_DEFAULT
,
/* drop_list = */
true
));
}
else
if
(
!
field
->
is_repeated
())
{
// Singular fields, receive a |value| as the field's value ; set this as
// the field's value directly.
}
else
{
// Singular fields, and packed repeated fields, receive a |value| either
// as the field's value or as the array of all the field's values; set
// this as the field's value directly.
printer
->
Print
(
" msg.set$name$(value);
\n
"
,
"name"
,
JSGetterName
(
options
,
field
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment