File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1926,6 +1926,20 @@ MessageFactory* TextFormat::Finder::FindExtensionFactory(
19261926
19271927// ===========================================================================
19281928
1929+ // Note: this value is intentionally unbounded by default. This is due to the
1930+ // use-cases of TextProto primarily being to parse trusted inputs, alongside a
1931+ // strong need to avoid breaking long-standing and working as intended usages
1932+ // parsing messages which exceed depth 100. Use-cases which need to limit this
1933+ // (e.g. anything parsing of untrusted TextProto inputs) must explicitly opt
1934+ // into a limit.
1935+ //
1936+ // At a future date we may consider reducing this default, but we have
1937+ // no concrete plans to do so. PRs proposing to reduce this value to 100
1938+ // unfortunately will not be accepted at this time.
1939+ //
1940+ // See comment on TextFormat class in text_format.h for more info.
1941+ static constexpr int kDefaultRecursionLimit = std::numeric_limits<int >::max();
1942+
19291943TextFormat::Parser::Parser ()
19301944 : error_collector_(nullptr ),
19311945 finder_(nullptr ),
@@ -1938,7 +1952,7 @@ TextFormat::Parser::Parser()
19381952 allow_field_number_(false ),
19391953 allow_relaxed_whitespace_(false ),
19401954 allow_singular_overwrites_(false ),
1941- recursion_limit_(std::numeric_limits< int >::max() ) {}
1955+ recursion_limit_(kDefaultRecursionLimit ) {}
19421956
19431957namespace {
19441958
You can’t perform that action at this time.
0 commit comments