PARAM-VALUE 可以包含空格吗?

发布于 2024-12-13 09:45:51 字数 293 浏览 0 评论 0原文

正在阅读 syslog rfc

6.3.3. SD-PARAM

   Each SD-PARAM consists of a name, referred to as PARAM-NAME, and a
   value, referred to as PARAM-VALUE.

param-value 可以包含空格吗?或者它必须是一个单词名称?

Reading syslog rfc

6.3.3. SD-PARAM

   Each SD-PARAM consists of a name, referred to as PARAM-NAME, and a
   value, referred to as PARAM-VALUE.

Can param-value contain spaces? or it has to be a one-word name?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小鸟爱天空丶 2024-12-20 09:45:51

阅读该部分的其余部分:

为了支持国际字符,PARAM-VALUE 字段必须是
使用 UTF-8 编码。系统日志应用程序可以发出任何有效的 UTF-8
顺序。系统日志应用程序必须接受任何有效的 UTF-8 序列
以“最短形式”。如果控制字符是,它一定不会失败
存在于 PARAM-VALUE 中。系统日志应用程序可以修改消息
包含控制字符(例如,通过更改值为 0 的八位字节
(USASCII NUL)到四个字符“#000”)。原因如下
UNICODE TR36 [UNICODE-TR36]第 3.1 节中概述,发起者
必须以“最短形式”和收集器或中继对消息进行编码
不得以“非最短形式”解释消息。

在 PARAM-VALUE 内,字符 '"' (ABNF %d34)、'\' (ABNF %d92)、
和 ']' (ABNF %d93) 必须转义。这是必须避免的
解析错误。转义 ']' 并不是严格必要的,但确实是必要的
本规范要求避免系统日志应用
实施错误。这三个字符中的每一个都必须是
分别转义为 '\"'、'\\' 和 '\]'。使用反斜杠
用于控制字符转义以与其使用保持一致
在系统日志消息的其他部分以及
传统系统日志。

反斜杠('\')后跟所描述的三个字符中的任何一个
被认为是无效的转义序列。在这种情况下,反斜杠
必须被视为常规反斜杠,并且以下字符被视为
一个普通的角色。因此,无效序列不得更改。

空格字符当然可以是“有效的 UTF-8 序列”的一部分。第二段引用的段落提到了三个必须转义的字符;空格字符不是其中之一。

结论:PARAM-VALUE 字段可以包含空格。

Reading the rest of that section:

To support international characters, the PARAM-VALUE field MUST be
encoded using UTF-8. A syslog application MAY issue any valid UTF-8
sequence. A syslog application MUST accept any valid UTF-8 sequence
in the "shortest form". It MUST NOT fail if control characters are
present in PARAM-VALUE. The syslog application MAY modify messages
containing control characters (e.g., by changing an octet with value 0
(USASCII NUL) to the four characters "#000"). For the reasons
outlined in UNICODE TR36 [UNICODE-TR36], section 3.1, an originator
MUST encode messages in the "shortest form" and a collector or relay
MUST NOT interpret messages in the "non-shortest form".

Inside PARAM-VALUE, the characters '"' (ABNF %d34), '\' (ABNF %d92),
and ']' (ABNF %d93) MUST be escaped. This is necessary to avoid
parsing errors. Escaping ']' would not strictly be necessary but is
REQUIRED by this specification to avoid syslog application
implementation errors. Each of these three characters MUST be
escaped as '\"', '\\', and '\]' respectively. The backslash is used
for control character escaping for consistency with its use for
escaping in other parts of the syslog message as well as in
traditional syslog.

A backslash ('\') followed by none of the three described characters
is considered an invalid escape sequence. In this case, the backslash
MUST be treated as a regular backslash and the following character as
a regular character. Thus, the invalid sequence MUST not be altered.

A space character can certainly be part of a "valid UTF-8 sequence". The second quoted paragraph mentions three characters that must be escaped; the space character isn't one of them.

Conclusion: the PARAM-VALUE field can contain blanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文