Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosen the validation rule for Endpoint.host() #5814

Closed
ikhoon opened this issue Jul 17, 2024 · 0 comments · Fixed by #5854
Closed

Loosen the validation rule for Endpoint.host() #5814

ikhoon opened this issue Jul 17, 2024 · 0 comments · Fixed by #5854
Labels
Milestone

Comments

@ikhoon
Copy link
Contributor

ikhoon commented Jul 17, 2024

The underscore (_) character is not permitted in hostnames but is allowed in other contexts, such as DNS SRV records.

Currently, URI.parseServerAuthority() is used to validate a hostname of an Endpoint which disallows _.

final URI uri = new URI(null, authorityWithoutUserInfo, null, null, null).parseServerAuthority();

Armeria internally, Endpoint.host() is used for both DNS and a hostname of a URI. So I think we may loosen the validation rule to allow _ and use it for DNS queries and results.

Discord thread: https://discord.com/channels/1087271586832318494/1087272728177942629/1262912254333030451

@ikhoon ikhoon added the defect label Jul 17, 2024
@ikhoon ikhoon added this to the 1.30.0 milestone Jul 17, 2024
ikhoon added a commit to ikhoon/armeria that referenced this issue Aug 2, 2024
Motivation:

The authority part in a URI was validated by
`URI.parseServerAuthority()` which only allows alphanumeric characters,
`.` and `-`.
https://github.com/openjdk/jdk/blob/dc35f3e8a84c8f622a4cabb8aee0f96de2e2ea30/src/java.base/share/classes/java/net/URI.java#L3513-L3515

As a result, if underscore (`_`) is set in an authroity,
`URISyntaxException` is raised. We think the rule is too strict because
a request can also be sent to an instance when CSLB is used.
`_` is a valid character in a DNS record. Users may want to send a host
whose name is `beta_api.cloud.somewhere.com`.

Related: line#5814

Modifications:

- Remove the usage of `URI.parseServerAuthority()` in
  `SchemeAndAuthority`
- Parse a hostname and a port from a raw authority.

Result:

- Validation is relexed to permit underscores (_) in URI's authority.
- Closes line#5814
ikhoon added a commit to ikhoon/armeria that referenced this issue Aug 2, 2024
Motivation:

The authority part in a URI was validated by
`URI.parseServerAuthority()` which only allows alphanumeric characters,
`.` and `-`.
https://github.com/openjdk/jdk/blob/dc35f3e8a84c8f622a4cabb8aee0f96de2e2ea30/src/java.base/share/classes/java/net/URI.java#L3513-L3515

As a result, if underscore (`_`) is set in an authority,
`URISyntaxException` is raised. We think the rule is too strict because
a request can also be sent to an instance when CSLB is used.
`_` is a valid character in a DNS record. Users may want to send a host
whose name is `beta_api.cloud.somewhere.com`.

Related: line#5814

Modifications:

- Remove the usage of `URI.parseServerAuthority()` in
  `SchemeAndAuthority`
- Parse a hostname and a port from a raw authority.

Result:

- Validation is relaxed to permit underscores (_) in URI's authority.
- Closes line#5814
ikhoon added a commit that referenced this issue Aug 8, 2024
Motivation:

The authority part in a URI was validated by
`URI.parseServerAuthority()` which only allows alphanumeric characters,
`.` and `-`.

https://github.com/openjdk/jdk/blob/dc35f3e8a84c8f622a4cabb8aee0f96de2e2ea30/src/java.base/share/classes/java/net/URI.java#L3513-L3515

As a result, if underscore (`_`) is set in an authority,
`URISyntaxException` is raised. We think the rule is too strict because
a request can also be sent to an instance when CSLB is used. `_` is a
valid character in a DNS record. Users may want to send a request to a
host whose name is `beta_api.cloud.instance-123.somewhere.com`.

Related: #5814

Modifications:

- Remove the usage of `URI.parseServerAuthority()` in
`SchemeAndAuthority`
- Parse a hostname and a port from a raw authority.

Result:

- Validation is relaxed to permit underscores (_) in URI's authority.
- Closes #5814
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant