Skip to content

Fix ASCII validation issues, add support for international domain names - #19

Merged
otherjoel merged 4 commits into
mainfrom
idn-support
Sep 26, 2026
Merged

otherjoel merged 4 commits into
mainfrom
idn-support

Conversation

@otherjoel

Copy link
Copy Markdown
Owner

This PR fixes some longstanding validation issues (list at the end below). It also adds support for converting internationalized domain names to ASCII according to IDNA2008, including the host of a URL and the domain of an email address.

Important

As a result of these fixes, some strings which used to validate in earlier versions may not pass validation going forward:

  • Domain names that are empty or longer than 253 characters, and URLs with an empty host (such as https:// or file:///path)
  • Domain names with -- in the third and fourth positions of a label, unless the label is a valid A-label (xn--…)
  • URLs that contain non-ASCII characters (use url-string->ascii to convert them)
  • Email addresses whose local part contains characters outside the allowed set (such as spaces, quotation marks or non-ASCII characters), starts or ends with a period, or contains two periods in a row
  • Tag URI authorities (the first argument to mint-tag-uri) that contain uppercase letters, and email authorities with characters other than a–z, 0–9, -, . and _ before the @. A feed that uses such an authority will need new IDs, and feed readers may show its entries again.

A preview of the documentation updates in this PR is live at https://joeldueck.com/what-about/splitflap/. In particular, see:

Changes

  • dns-domain? now allows labels that start with a digit (per RFC 1123) and labels of up to 63 bytes; limits domains to 253 bytes; and no longer accepts the empty string. As a result, valid-url-string? no longer accepts URLs with an empty host.

  • email-address? now checks the entire local part (previously one allowed character was enough), and it now applies exactly the same rules as validate-email-address. Both accept uppercase letters and `, and both reject local parts that start or end with a period or contain two periods in a row.

  • Added tag-authority?. mint-tag-uri now requires a lowercase authority, and allows only a–z, 0–9, -, . and _ before the @ of an email authority, per RFC 4151. The W3C Feed Validator rejects Atom feeds whose tag URIs use other authorities.

  • Added domain->ascii, url-string->ascii and email-address->ascii, which convert internationalized domain names to ASCII according to IDNA2008 (see Internationalized domain names). url-string->ascii also percent-encodes any other non-ASCII characters, following RFC 3987. email-address->ascii converts only the domain, because a non-ASCII local part has no ASCII form.

  • dns-domain? now requires labels with -- in the third and fourth positions to be valid A-labels, and valid-url-string? now rejects URLs that contain non-ASCII characters. The IDNA code and tables are loaded only when a domain name contains a non-ASCII or xn-- label.

  • The MIME type table (mime-types-by-ext) is now loaded the first time it is used, rather than whenever Splitflap is loaded.

  • Corrected the docs for dns-domain? (length limits) and for the email functions (length limits, allowed characters, and the result of validate-email-address).

Closes #14
Closes #15
Closes #16
Closes #17
Closes #18

@otherjoel
otherjoel merged commit bd8b80e into main Sep 26, 2026
2 checks passed
@otherjoel
otherjoel deleted the idn-support branch September 26, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant