What does “abempty” mean in the term “path-abempty” in the context of RFC3986?

北战南征 提交于 2019-12-07 06:05:43

问题


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.


回答1:


"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:///



回答3:


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!



来源:https://stackoverflow.com/questions/40905666/what-does-abempty-mean-in-the-term-path-abempty-in-the-context-of-rfc3986

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!