Skip to content

Escape resolved hostnames in HTML connection output - #3664

Open
wasphin wants to merge 2 commits into
apache:masterfrom
wasphin:fix-connection-hostname-output
Open

wasphin wants to merge 2 commits into
apache:masterfrom
wasphin:fix-connection-hostname-output

Conversation

@wasphin

@wasphin wasphin commented Oct 25, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Problem Summary:

The connections page inserts resolved hostnames directly into HTML output.

What is changed and the side effects?

Changed:

  • Escape resolved names when rendering HTML connection rows.
  • Preserve plain-text output.
  • Cover connections output with hostname display enabled.

Side effects:

  • Performance effects: HTML escaping is applied only when hostname display and HTML output are enabled.
  • Breaking backward compatibility: None.

Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression tests need deterministic escaping coverage and matching resolver buffer sizes to avoid environment-dependent failures.

2 open issues
What changed in this PR

This PR escapes resolved hostnames in bRPC’s HTML connections page while preserving plain-text output.

Changes:

  • Pass the output format to hostname rendering for both normal and broken connections.
  • Add hostname-enabled checks for HTML and plain-text responses.
  • Use an ephemeral port in connection tests.
File Description
test/​brpc_builtin_service_unittest.cpp Adds hostname-display coverage and uses an ephemeral server port.
src/​brpc/​builtin/​connections_service.cpp Escapes resolved hostnames only when rendering HTML.

Review effort: Balanced

EXPECT_EQ(expect_type, cntl.http_response().content_type());
CheckContent(cntl, buf);
if (brpc::FLAGS_show_hostname_instead_of_ip) {
char hostname[256];
Comment on lines +709 to +713
TEST_F(BuiltinServiceTest, connections_with_hostnames) {
GFLAGS_NAMESPACE::FlagSaver flag_saver;
brpc::FLAGS_show_hostname_instead_of_ip = true;
TestConnections(false);
TestConnections(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants