Case-Sensitive String Support in ABNF
updates
- rfc-5234 — Augmented BNF for Syntax Specifications: ABNF
Extracted elements (8)
Prior ABNF (RFC 5234) only supported case-insensitive string literals; achieving case-sensitive matching required specifying individual characters by numeric value (e.g., %d97 %d98 %d99), which was inconvenient and error prone both to write and read. This document introduces explicit prefix syntax to address that gap.
Using a prefixed literal such as '%s"aBc"' for case-sensitive matching has a clear readability advantage over the prior practice of specifying each character numerically (e.g., %d97 %d98 %d99 or %x61.62.63), motivating the new syntax.
Both '%i"aBc"' and the undecorated '"abc"' match the same set of strings ('abc', 'Abc', 'aBc', etc.), ensuring that existing ABNF grammars without prefixes continue to behave identically after this extension is adopted.
A quoted string with no prefix is treated as case-insensitive and is equivalent to using the '%i' prefix, preserving backward compatibility with prior ABNF implementations.
The 'quoted-string' terminal is defined as DQUOTE followed by zero or more printable US-ASCII characters (SP and VCHAR, excluding DQUOTE itself, i.e., %x20-21 / %x23-7E), closed by DQUOTE.
Two type prefixes are introduced for ABNF quoted string literals: '%s' denotes case-sensitive matching and '%i' denotes case-insensitive matching. These prefixes parallel the type prefix convention already used with numeric values in ABNF.
The RFC states that security is truly believed to be irrelevant to this document, as the change is purely a syntactic extension to ABNF notation with no impact on protocol security properties.
The updated 'char-val' rule is: char-val = case-insensitive-string / case-sensitive-string; case-insensitive-string = ["%i"] quoted-string; case-sensitive-string = "%s" quoted-string; quoted-string = DQUOTE *(%x20-21 / %x23-7E) DQUOTE. This replaces the char-val rule in Section 4 of RFC 5234.