Skip to content

Commit 51b2739

Browse files
committed
fix: allow underscores in FQDNs/subdomains
1 parent aad8234 commit 51b2739

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/minecraft/server/blocklist/FqdnValidator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { singleton } from 'tsyringe';
33
@singleton()
44
export default class FqdnValidator {
55
// A very simple pattern to not risk false-positives (based on RFC 1034)
6-
private readonly FQDN_PATTERN = /^(?:[a-z0-9-]{1,63}\.)+[a-z][a-z0-9-]{0,63}\.?$/i;
6+
private readonly FQDN_PATTERN = /^(?:[a-z0-9_-]{1,63}\.)+[a-z][a-z0-9-]{0,63}\.?$/i;
77

88
validateFqdn(input: string): boolean {
99
return input.length <= 255 && this.FQDN_PATTERN.test(input);

tests/unit/minecraft/server/FqdnValidator.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ describe('valid FQDNs', () => {
77
['foobar.example.com'],
88
['foobar.example.com.'],
99
['foo.bar'],
10-
['a.b']
10+
['a.b'],
11+
['foo_bar.example.com']
1112
])('%s', (input) => {
1213
expect(new FqdnValidator().validateFqdn(input)).toBe(true);
1314
});

0 commit comments

Comments
 (0)