|
|
@ -48,6 +48,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "absl/container/btree_set.h" |
|
|
|
#include "absl/container/btree_set.h" |
|
|
|
#include "absl/strings/ascii.h" |
|
|
|
#include "absl/strings/ascii.h" |
|
|
|
|
|
|
|
#include "absl/strings/cord.h" |
|
|
|
#include "absl/strings/escaping.h" |
|
|
|
#include "absl/strings/escaping.h" |
|
|
|
#include "absl/strings/numbers.h" |
|
|
|
#include "absl/strings/numbers.h" |
|
|
|
#include "absl/strings/str_cat.h" |
|
|
|
#include "absl/strings/str_cat.h" |
|
|
@ -62,6 +63,7 @@ |
|
|
|
#include "google/protobuf/io/tokenizer.h" |
|
|
|
#include "google/protobuf/io/tokenizer.h" |
|
|
|
#include "google/protobuf/io/zero_copy_stream.h" |
|
|
|
#include "google/protobuf/io/zero_copy_stream.h" |
|
|
|
#include "google/protobuf/io/zero_copy_stream_impl.h" |
|
|
|
#include "google/protobuf/io/zero_copy_stream_impl.h" |
|
|
|
|
|
|
|
#include "google/protobuf/io/zero_copy_stream_impl_lite.h" |
|
|
|
#include "google/protobuf/map_field.h" |
|
|
|
#include "google/protobuf/map_field.h" |
|
|
|
#include "google/protobuf/message.h" |
|
|
|
#include "google/protobuf/message.h" |
|
|
|
#include "google/protobuf/reflection_mode.h" |
|
|
|
#include "google/protobuf/reflection_mode.h" |
|
|
@ -1670,8 +1672,8 @@ TextFormat::Parser::~Parser() {} |
|
|
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
namespace { |
|
|
|
|
|
|
|
|
|
|
|
bool CheckParseInputSize(absl::string_view input, |
|
|
|
template <typename T> |
|
|
|
io::ErrorCollector* error_collector) { |
|
|
|
bool CheckParseInputSize(T& input, io::ErrorCollector* error_collector) { |
|
|
|
if (input.size() > INT_MAX) { |
|
|
|
if (input.size() > INT_MAX) { |
|
|
|
error_collector->RecordError( |
|
|
|
error_collector->RecordError( |
|
|
|
-1, 0, |
|
|
|
-1, 0, |
|
|
@ -1709,6 +1711,13 @@ bool TextFormat::Parser::ParseFromString(absl::string_view input, |
|
|
|
return Parse(&input_stream, output); |
|
|
|
return Parse(&input_stream, output); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TextFormat::Parser::ParseFromCord(const absl::Cord& input, |
|
|
|
|
|
|
|
Message* output) { |
|
|
|
|
|
|
|
DO(CheckParseInputSize(input, error_collector_)); |
|
|
|
|
|
|
|
io::CordInputStream input_stream(&input); |
|
|
|
|
|
|
|
return Parse(&input_stream, output); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input, |
|
|
|
bool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input, |
|
|
|
Message* output) { |
|
|
|
Message* output) { |
|
|
|
ParserImpl parser(output->GetDescriptor(), input, error_collector_, finder_, |
|
|
|
ParserImpl parser(output->GetDescriptor(), input, error_collector_, finder_, |
|
|
@ -1770,6 +1779,11 @@ bool TextFormat::Parser::ParseFieldValueFromString(const std::string& input, |
|
|
|
return Parser().ParseFromString(input, output); |
|
|
|
return Parser().ParseFromString(input, output); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* static */ bool TextFormat::ParseFromCord(const absl::Cord& input, |
|
|
|
|
|
|
|
Message* output) { |
|
|
|
|
|
|
|
return Parser().ParseFromCord(input, output); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* static */ bool TextFormat::MergeFromString(absl::string_view input, |
|
|
|
/* static */ bool TextFormat::MergeFromString(absl::string_view input, |
|
|
|
Message* output) { |
|
|
|
Message* output) { |
|
|
|
return Parser().MergeFromString(input, output); |
|
|
|
return Parser().MergeFromString(input, output); |
|
|
|