Skip to content

Commit

Permalink
fix: allow underscores in FQDNs/subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
SpraxDev committed Nov 19, 2024
1 parent aad8234 commit 51b2739
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/minecraft/server/blocklist/FqdnValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { singleton } from 'tsyringe';
@singleton()
export default class FqdnValidator {
// A very simple pattern to not risk false-positives (based on RFC 1034)
private readonly FQDN_PATTERN = /^(?:[a-z0-9-]{1,63}\.)+[a-z][a-z0-9-]{0,63}\.?$/i;
private readonly FQDN_PATTERN = /^(?:[a-z0-9_-]{1,63}\.)+[a-z][a-z0-9-]{0,63}\.?$/i;

validateFqdn(input: string): boolean {
return input.length <= 255 && this.FQDN_PATTERN.test(input);
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/minecraft/server/FqdnValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ describe('valid FQDNs', () => {
['foobar.example.com'],
['foobar.example.com.'],
['foo.bar'],
['a.b']
['a.b'],
['foo_bar.example.com']
])('%s', (input) => {
expect(new FqdnValidator().validateFqdn(input)).toBe(true);
});
Expand Down

0 comments on commit 51b2739

Please sign in to comment.