7

See: https://tools.ietf.org/html/rfc3986#section-3

And: https://tools.ietf.org/html/rfc3986#section-3.3

The origin of "abempty" is mysterious to me, and a quick search didn't turn up any definitions of it.

James Shapiro
  • 2,796
  • 1
  • 22
  • 26

3 Answers3

8

"abempty", as it states in the comments to the right of its usage in the rfc you reference, means that its value can be either an absolute path or empty so (abempty).

2

“Abempty”, meaning away from empty, describes the path’s relationship to its preceding authority. Where path-abempty is relevant, the hier-part consists of “//”, authority, and path-abempty. The authority component may be zero length – scheme:/// is a valid URI.

However, when the authority is zero length and the path is empty, there is no way to distinguish the two components, hence a path-abempty path - it "begins with "/" or is empty" (Section 3.3) depending on the circumstances.

Source: http://w3-org.9356.n7.nabble.com/path-abempty-in-URI-td170118.html (See Fielding's response to Petch.)

NB The word “abempty” is not a portmanteau of the words absolute and empty.

Please:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

The hier-part is not optional in the context of a "generic" URI.

hier-part = ("//" authority path-abempty) / path-absolute / path-rootless / path-empty

The double slashes, interestingly enough, are not optional where path-abempty is relevant. And, jumping ahead a little, the authority may be zero-length:

reg-name = *( unreserved / pct-encoded / sub-delims )

Path-abempty is relevant where the hier-part consists of “//”, authority, and path-abempty. Path-abempty is defined as:

path-abempty = *( "/" segment )

The RFC states, “When authority is present, the path must either be empty or begin with a slash ("/") character.” If the reg-name is zero length, a casual reading of that statement might suggest that the following URI is valid:

scheme://

It’s not. The very next sentence states, “When authority is not present, the path cannot begin with two slash characters (‘//’).” This means that in parsing our URI that begins with “scheme://” we indicate the possibility of a zero-length authority and a zero-length path - otherwise we could stop right there because the URI would be invalid.

In this case, not the common case by any means, the zero-length authority cannot be discerned from the zero-length path. Hence, when the authority is zero-length, WE DO NOT HAVE A CHOICE, the path MUST begin with a forward slash (more precisely, it must match path-abempty) and discern the path from the authority; otherwise, and I will say it again: the URI would be invalid.

The word “abempty” doesn’t imply that the path may be absolute or empty. The word means that the path must distinguish itself from the authority, hence it is abempty i.e., away from empty.

Examples:

This URI is ambiguous because even if it has a zero-length authority and a zero-length path, there is no way to discern it from an invalid URI that omits the authority and has a path that starts with two forward slashes.

scheme://

This URI is not ambiguous as it clearly contains a zero-length authority and a path-abempty path.

scheme:///
0

Given its definition and context in RFC 3986, Section 3.3: I'm confident that abempty is a portmanteau of absolute and empty; as opposed to empty with a Latin ab-prefix.

Possible path patterns are defined as:

path-abempty  = *( "/" segment )                    ; begins with "/" or is empty
path-absolute = "/" [ segment-nz *( "/" segment ) ] ; begins with "/" but not "//"
path-noscheme = segment-nz-nc *( "/" segment )      ; begins with a non-colon segment
path-rootless = segment-nz *( "/" segment )         ; begins with a segment
path-empty    = 0<pchar>                            ; zero characters
  • Path-abempty is essentially an extended path-absolute, combined with path-empty.
  • Path-absolute-or-empty becomes path-abempty.

Disclaimer

My assertion is based solely on inferential conjectures, as I couldn't find the word's etymology, or who coined it. So if anyone has relevant knowledge, to contradict or corroborate: Please, do share!

Payne
  • 319
  • 1
  • 6
  • It's not like BNF symbols are expected to really mean anything. – tripleee Jan 07 '19 at 05:19
  • "Path-absolute-or-empty becomes path-abempty." What is "///"? It's not path-absolute. It's not path-empty. It is path-abempty. –  Jan 08 '19 at 00:25
  • Correct. As noted by "extended" in the preceding bullet point. I can bold out that word, and perhaps use _Path-extended-absolute-or-empty_ to make it more explicit. May be a bit more distracting, though. – Payne Jan 09 '19 at 16:26
  • I noticed the "extended", which is why I referenced the second bullet. With regard to the first bullet, I can't see how path-abempty is essentially an extension of path-absolute, as they are not used in the same URI context. Path-absolute is relevant only when the authority is not present. "Not present" meaning that it is not part of the URI - not just that it is zero-length. –  Jan 09 '19 at 20:06