|
|
@ -2527,6 +2527,10 @@ void TextFormat::Printer::PrintField(const Message& message, |
|
|
|
PrintFieldName(message, field_index, count, reflection, field, generator); |
|
|
|
PrintFieldName(message, field_index, count, reflection, field, generator); |
|
|
|
|
|
|
|
|
|
|
|
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { |
|
|
|
if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { |
|
|
|
|
|
|
|
if (TryRedactFieldValue(message, field, generator, |
|
|
|
|
|
|
|
/*insert_value_separator=*/true)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
const FastFieldValuePrinter* printer = GetFieldPrinter(field); |
|
|
|
const FastFieldValuePrinter* printer = GetFieldPrinter(field); |
|
|
|
const Message& sub_message = |
|
|
|
const Message& sub_message = |
|
|
|
field->is_repeated() |
|
|
|
field->is_repeated() |
|
|
@ -2607,9 +2611,8 @@ void TextFormat::Printer::PrintFieldValue(const Message& message, |
|
|
|
<< "Index must be -1 for non-repeated fields"; |
|
|
|
<< "Index must be -1 for non-repeated fields"; |
|
|
|
|
|
|
|
|
|
|
|
const FastFieldValuePrinter* printer = GetFieldPrinter(field); |
|
|
|
const FastFieldValuePrinter* printer = GetFieldPrinter(field); |
|
|
|
if (redact_debug_string_ && field->options().debug_redact()) { |
|
|
|
if (TryRedactFieldValue(message, field, generator, |
|
|
|
IncrementRedactedFieldCounter(); |
|
|
|
/*insert_value_separator=*/false)) { |
|
|
|
generator->PrintString("[REDACTED]"); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2829,6 +2832,31 @@ void TextFormat::Printer::PrintUnknownFields( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TextFormat::Printer::TryRedactFieldValue( |
|
|
|
|
|
|
|
const Message& message, const FieldDescriptor* field, |
|
|
|
|
|
|
|
BaseTextGenerator* generator, bool insert_value_separator) const { |
|
|
|
|
|
|
|
auto do_redact = [&](absl::string_view replacement) { |
|
|
|
|
|
|
|
IncrementRedactedFieldCounter(); |
|
|
|
|
|
|
|
if (insert_value_separator) { |
|
|
|
|
|
|
|
generator->PrintMaybeWithMarker(MarkerToken(), ": "); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
generator->PrintString(replacement); |
|
|
|
|
|
|
|
if (insert_value_separator) { |
|
|
|
|
|
|
|
if (single_line_mode_) { |
|
|
|
|
|
|
|
generator->PrintLiteral(" "); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
generator->PrintLiteral("\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (redact_debug_string_ && field->options().debug_redact()) { |
|
|
|
|
|
|
|
do_redact("[REDACTED]"); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} // namespace protobuf
|
|
|
|
} // namespace protobuf
|
|
|
|
} // namespace google
|
|
|
|
} // namespace google
|
|
|
|
|
|
|
|
|
|
|
|