Do not skip over unknown elements at the root level
OnUnknownElement() should be called to handle them. Change-Id: Iebd99631f094e95d0c3e75952930962e15826bac
This commit is contained in:
parent
837746f4d2
commit
80685d3865
@ -13,6 +13,7 @@
|
|||||||
#include "src/ebml_parser.h"
|
#include "src/ebml_parser.h"
|
||||||
#include "src/master_parser.h"
|
#include "src/master_parser.h"
|
||||||
#include "src/segment_parser.h"
|
#include "src/segment_parser.h"
|
||||||
|
#include "src/unknown_parser.h"
|
||||||
#include "webm/element.h"
|
#include "webm/element.h"
|
||||||
|
|
||||||
namespace webm {
|
namespace webm {
|
||||||
@ -123,7 +124,7 @@ class WebmParser::DocumentParser {
|
|||||||
if (child_metadata_.size == kUnknownElementSize) {
|
if (child_metadata_.size == kUnknownElementSize) {
|
||||||
return Status(Status::kIndefiniteUnknownElement);
|
return Status(Status::kIndefiniteUnknownElement);
|
||||||
}
|
}
|
||||||
child_parser_ = &skip_parser_;
|
child_parser_ = &unknown_parser_;
|
||||||
}
|
}
|
||||||
state_ = State::kGettingAction;
|
state_ = State::kGettingAction;
|
||||||
continue;
|
continue;
|
||||||
@ -217,6 +218,9 @@ class WebmParser::DocumentParser {
|
|||||||
// The parser used when skipping elements (if the element's size is known).
|
// The parser used when skipping elements (if the element's size is known).
|
||||||
SkipParser skip_parser_;
|
SkipParser skip_parser_;
|
||||||
|
|
||||||
|
// The parser used for unknown children.
|
||||||
|
UnknownParser unknown_parser_;
|
||||||
|
|
||||||
// The callback used when skipping elements.
|
// The callback used when skipping elements.
|
||||||
SkipCallback skip_callback_;
|
SkipCallback skip_callback_;
|
||||||
|
|
||||||
|
@ -106,6 +106,27 @@ TEST_F(WebmParserTest, DefaultParse) {
|
|||||||
EXPECT_EQ(Status::kOkCompleted, status.code);
|
EXPECT_EQ(Status::kOkCompleted, status.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WebmParserTest, UnknownElement) {
|
||||||
|
BufferReader reader = {
|
||||||
|
0x80, // ID = 0x80.
|
||||||
|
0x80, // Size = 0.
|
||||||
|
};
|
||||||
|
|
||||||
|
MockCallback callback;
|
||||||
|
{
|
||||||
|
InSequence dummy;
|
||||||
|
|
||||||
|
ElementMetadata metadata = {static_cast<Id>(0x80), 2, 0, 0};
|
||||||
|
EXPECT_CALL(callback, OnElementBegin(metadata, NotNull())).Times(1);
|
||||||
|
EXPECT_CALL(callback, OnUnknownElement(metadata, NotNull(), NotNull()))
|
||||||
|
.Times(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
WebmParser parser;
|
||||||
|
Status status = parser.Feed(&callback, &reader);
|
||||||
|
EXPECT_EQ(Status::kOkCompleted, status.code);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(WebmParserTest, SeekEbml) {
|
TEST_F(WebmParserTest, SeekEbml) {
|
||||||
BufferReader reader = {
|
BufferReader reader = {
|
||||||
0x1A, 0x45, 0xDF, 0xA3, // ID = 0x1A45DFA3 (EBML).
|
0x1A, 0x45, 0xDF, 0xA3, // ID = 0x1A45DFA3 (EBML).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user