Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 542053833
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jun 20, 2023
1 parent 4d9bbac commit ff847ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/google/protobuf/text_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2872,20 +2872,20 @@ void TextFormat::Printer::PrintUnknownFields(
}
}

namespace {
namespace internal {

// Check if the field is sensitive and should be redacted.
bool ShouldRedactField(const FieldDescriptor* field) {
if (field->options().debug_redact()) return true;
return false;
}

} // namespace
} // namespace internal

bool TextFormat::Printer::TryRedactFieldValue(
const Message& message, const FieldDescriptor* field,
BaseTextGenerator* generator, bool insert_value_separator) const {
if (ShouldRedactField(field)) {
if (internal::ShouldRedactField(field)) {
if (redact_debug_string_) {
IncrementRedactedFieldCounter();
if (insert_value_separator) {
Expand Down
1 change: 1 addition & 0 deletions src/google/protobuf/text_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ PROTOBUF_EXPORT extern std::atomic<bool> enable_debug_text_format_marker;
PROTOBUF_EXPORT extern std::atomic<bool> enable_debug_text_detection;
PROTOBUF_EXPORT extern std::atomic<bool> enable_debug_text_redaction;
PROTOBUF_EXPORT int64_t GetRedactedFieldCount();
PROTOBUF_EXPORT bool ShouldRedactField(const FieldDescriptor* field);

// This enum contains all the APIs that convert protos to human-readable
// formats. A higher-level API must correspond to a greater number than any
Expand Down

0 comments on commit ff847ba

Please sign in to comment.