Skip to content

Commit

Permalink
Relax recent SNI restrictions
Browse files Browse the repository at this point in the history
Signed-off-by: John Howard <[email protected]>
  • Loading branch information
howardjohn committed Nov 5, 2024
1 parent 58d60eb commit 44765c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion source/common/common/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ std::string StringUtil::sanitizeInvalidHostname(const absl::string_view source)
std::string ret_str = std::string(source);
bool sanitized = false;
for (size_t i = 0; i < ret_str.size(); ++i) {
if (absl::ascii_isalnum(ret_str[i]) || ret_str[i] == '.' || ret_str[i] == '-') {
if (absl::ascii_isalnum(ret_str[i]) || ret_str[i] == '.' || ret_str[i] == '-' ||
ret_str[i] == '_') {
continue;
}
sanitized = true;
Expand Down
4 changes: 2 additions & 2 deletions source/common/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ class StringUtil {

/**
* Sanitize host name strings for logging purposes. Replace invalid hostname characters (anything
* that's not alphanumeric, hyphen, or period) with underscore. The sanitized string is not a
* valid host name.
* that's not alphanumeric, hyphen, or period) with underscore. The sanitized string
* is not a valid host name.
* @param source supplies the string to sanitize.
* @return sanitized string.
*/
Expand Down
9 changes: 9 additions & 0 deletions test/common/formatter/substitution_formatter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,15 @@ TEST(SubstitutionFormatterTest, streamInfoFormatter) {
ProtoEq(ValueUtil::nullValue()));
}

{
StreamInfoFormatter upstream_format("REQUESTED_SERVER_NAME");
std::string requested_server_name = "outbound_.8080_._.example.com";
stream_info.downstream_connection_info_provider_->setRequestedServerName(requested_server_name);
EXPECT_EQ("outbound_.8080_._.example.com", upstream_format.formatWithContext({}, stream_info));
EXPECT_THAT(upstream_format.formatValueWithContext({}, stream_info),
ProtoEq(ValueUtil::stringValue("outbound_.8080_._.example.com")));
}

{
StreamInfoFormatter upstream_format("REQUESTED_SERVER_NAME");
std::string requested_server_name = "stub-server";
Expand Down

0 comments on commit 44765c1

Please sign in to comment.