RFC 7405

Case-Sensitive String Support in ABNF

πŸ“… published December 2014, from ietf

RFC 7405: Case-Sensitive String Support in ABNF βœ¨πŸŽ€

okay bestie, this one is lowkey small but it slaps πŸ’… it's by Paul Kyzivat, published December 2014, and it's on the Standards Track (ISSN 2070-1721). it updates RFC 5234, which is the full ABNF spec, so we're basically giving ABNF a little glow-up πŸ¦‹


Abstract 🌸

this doc extends the base ABNF (Augmented Backus-Naur Form) definition so you can write US-ASCII string literals that get matched case-sensitively πŸ”₯

Status of This Memo πŸ“œ

this is an Internet Standards Track document πŸ’–

this document is a product of the Internet Engineering Task Force (IETF). it represents the consensus of the IETF community. it has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). further info on Internet Standards is in Section 2 of RFC 5741.

info about the current status of this doc, any errata, and how to give feedback can be found at http://www.rfc-editor.org/info/rfc7405.

Copyright (c) 2014 IETF Trust and the persons identified as the document authors. All rights reserved.

this document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) as in effect on the date of publication of this document. please review those docs carefully, because they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions, and they are provided without warranty as described in the Simplified BSD License.

Table of Contents 🧚

1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
2.  Updates to RFC 5234 . . . . . . . . . . . . . . . . . . . . .   2
  2.1.  Terminal Values - Literal Text Strings  . . . . . . . . .   3
  2.2.  ABNF Definition of ABNF - char-val  . . . . . . . . . . .   4
3.  Security Considerations . . . . . . . . . . . . . . . . . . .   4
4.  Normative References  . . . . . . . . . . . . . . . . . . . .   4
Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .   4

1. Introduction πŸŽ€

okay so the base ABNF definition supports US-ASCII string literals, and matching them is case-insensitive πŸ™ˆ that's often exactly what we want! but sometimes you need case-sensitive matching, and the only way to get it was to spell out each character by its numeric value. literally inconvenient and so easy to mess up when you're writing or reading it 😭

so this doc extends ABNF to have two types of US-ASCII string literal. one is matched case-sensitively, the other case-insensitively. they're marked with type prefixes that look like the ones already used for numeric values. if there's no prefix, matching is case-insensitive, which keeps the old behavior ✨

this document is structured as a set of changes to the full ABNF specification [RFC5234].

2. Updates to RFC 5234 πŸ’…

this doc makes changes to two parts of [RFC5234]:

  • replace the last half of Section 2.3 of [RFC5234] (starting with "ABNF permits the specification of literal text strings") with the contents of Section 2.1.
  • replace the <char-val> rule in Section 4 of [RFC5234] with the contents of Section 2.2.

2.1. Terminal Values - Literal Text Strings πŸ’–

ABNF lets you write literal text strings directly, inside quotation marks. so:

command     =  "command string"

literal text strings are read as a concatenated set of printable characters.

NOTE:

the character set for these strings is US-ASCII.

literal text strings in ABNF may be either case sensitive or case insensitive. the kind of matching is marked by a prefix on the quoted string. these prefixes are allowed:

%s          =  case-sensitive
%i          =  case-insensitive

to stay consistent with older ABNF implementations, having no prefix means the string is case insensitive, same as using the %i prefix πŸ¦‹

so:

rulename = %i"aBc"

and:

rulename = "abc"

will both match "abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC", and "ABC". iconic behavior, no notes πŸ’…

in contrast:

rulename = %s"aBc"

will match only "aBc" and will not match "abc", "Abc", "abC", "ABc", "aBC", "AbC", or "ABC". very picky, very specific πŸ‘‘

in the past, case-sensitive rules were made by spelling out individual characters numerically. for example:

rulename    =  %d97 %d98 %d99

or:

rulename    =  %x61.62.63

will match only the string made of lowercase characters, abc. a prefixed literal text string is way more readable than the old way, so this is a real W πŸ™Œ

2.2. ABNF Definition of ABNF - char-val 🌈

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
                       ; quoted string of SP and VCHAR
                       ;  without DQUOTE

3. Security Considerations πŸ’€

the doc says security is truly believed to be irrelevant to this document. so no drama here, periodt πŸ™ˆ

⚠️ the doc itself is the only thing being said here, so take it as written and don't stretch it.

4. Normative References πŸ“š

[RFC5234]  Crocker, D. and P. Overell, "Augmented BNF for Syntax
           Specifications: ABNF", STD 68, RFC 5234, January 2008,
           <http:/www.rfc-editor.org/info/rfc5234>.

Author's Address 🫢

Paul Kyzivat Massachusetts United States

EMail: pkyzivat@alum.mit.edu

πŸ“¦ where this page comes from