also looking at this
fix: allow underscores in domain labels
#2057
2 files
+19
-2
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -41,7 +41,7 @@ export class DnsClient { | ||
| 41 | 41 | * - Start/end dots |
| 42 | 42 | * - Overall length (max 253 characters) |
| 43 | 43 | * - Label length (max 63 characters) |
| 44 | * - Valid characters (a-z, 0-9, -) | |
| 44 | * - Valid characters (a-z, 0-9, -, _) | |
| 45 | 45 | * |
| 46 | 46 | * @param domain - The domain name to validate |
| 47 | 47 | * @throws {Error} If the domain name is invalid |
| @@ -70,7 +70,7 @@ export class DnsClient { | ||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Check label characters |
| 73 | if (!/^[a-z0-9-]+$/i.test(label)) { | |
| 73 | if (!/^[a-z0-9_-]+$/i.test(label)) { | |
| 74 | 74 | throw new Error(`Invalid characters in domain label: ${label}`) |
| 75 | 75 | } |
| 76 | 76 | } |
| @@ -187,6 +187,23 @@ describe('DnsClient', () => { | ||
| 187 | 187 | })).toThrow() |
| 188 | 188 | }) |
| 189 | 189 | |
| 190 | it('should accept underscores in domain labels (DKIM, DMARC, SRV)', () => { | |
| 191 | expect(() => new DnsClient({ | |
| 192 | domains: ['selector1._domainkey.example.com'], | |
| 193 | type: 'TXT', | |
| 194 | })).not.toThrow() | |
| 195 | ||
| 196 | expect(() => new DnsClient({ | |
| 197 | domains: ['_dmarc.example.com'], | |
| 198 | type: 'TXT', | |
| 199 | })).not.toThrow() | |
| 200 | ||
| 201 | expect(() => new DnsClient({ | |
| 202 | domains: ['_sip._tcp.example.com'], | |
| 203 | type: 'SRV', | |
| 204 | })).not.toThrow() | |
| 205 | }) | |
| 206 | ||
| 190 | 207 | it('should handle invalid record types', () => { |
| 191 | 208 | expect(() => new DnsClient({ |
| 192 | 209 | domains: ['example.com'], |