forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: modify authority validation to allow @ character (envoyproxy#35602
) Envoy uses the `authorityIsValid()` to validate the authority header for both H/1 and H/2 codecs. Previously Envoy used the nghttp2 validator and in envoyproxy#24943 this was changed to oghttp2's implementation. The two implementations differ in the way they handle the "@" character (nghttp2 allows it, and oghttp2 doesn't). According to the H/2 spec, the "@" character is not allowed as part of the authority header. However, for H/1 it is allowed as part of the "user-info@host:port" structure of the authority header. This PR changes the validator to be similar to the nghttp2 implemenation. The change can be temporarily dis In the future, when Envoy fully supports UHV (envoyproxy#10646), the H/1 and H/2 validation parts should be decoupled, and the oghttp2 authority validation can be used for H/2. --------- Signed-off-by: Adi Suissa-Peleg <[email protected]>
- Loading branch information
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1152,6 +1152,24 @@ TEST(HeaderIsValidTest, ValidHeaderValuesAreAccepted) { | |
TEST(HeaderIsValidTest, AuthorityIsValid) { | ||
EXPECT_TRUE(HeaderUtility::authorityIsValid("strangebutlegal$-%&'")); | ||
EXPECT_FALSE(HeaderUtility::authorityIsValid("illegal{}")); | ||
// Validate that the "@" character is allowed. | ||
// TODO(adisuissa): Once the envoy.reloadable_features.internal_authority_header_validator | ||
// runtime flag is deprecated, this test should only validate the assignment | ||
// to "true". | ||
{ | ||
TestScopedRuntime scoped_runtime; | ||
scoped_runtime.mergeValues( | ||
{{"envoy.reloadable_features.internal_authority_header_validator", "true"}}); | ||
EXPECT_TRUE(HeaderUtility::authorityIsValid("[email protected]'")); | ||
} | ||
{ | ||
TestScopedRuntime scoped_runtime; | ||
scoped_runtime.mergeValues( | ||
{{"envoy.reloadable_features.internal_authority_header_validator", "false"}}); | ||
// When the above is false, Envoy should use oghttp2's validator which will | ||
// reject the "@" character. | ||
EXPECT_FALSE(HeaderUtility::authorityIsValid("[email protected]'")); | ||
} | ||
} | ||
|
||
TEST(HeaderIsValidTest, IsConnect) { | ||
|