知名开源开发者 Sindre Sorhus 发布了一种名为 SOML(Sindre's Objectively Marvelous Language)的新配置文件格式草案 1。该格式的设计核心在于通过语法而非内容来确定数据类型,从而消除隐式类型转换和缩进依赖带来的歧义与安全风险 1。例如,在 SOML 中,'123' 被明确解析为字符串,而 123 则为整数,这一机制杜绝了类似 YAML 中将 country: no 误解析为布尔值 false 的情况 1。
为了提升数据表达的准确性,SOML 新增了对日期(如 2026-09-19)、时间点(如 2026-09-19T14:00:00Z)以及持续时间(如 30s, 1h30m)的原生支持 1。在结构上,该格式顶层无需大括号,键名除非包含空格否则无需引号,并使用换行符代替逗号分隔各项,同时支持 /* */ 块注释和 # 行注释 1。这种设计使得手写 JSON 通常可以直接作为有效的 SOML 使用,因为两者均使用冒号分隔且结构相似 1。
在安全性方面,SOML 明确不支持别名(Aliases)和标签(Tags),以防止 YAML 炸弹攻击,并禁止出现重复键 1。为确保一致性,规范提供了唯一的标准形式(Canonical form)用于哈希和签名操作,并附带了约 1000 个案例的符合性测试套件 1。目前,SOML 仍处于草案阶段,采用 MIT 许可证,但已有 JavaScript、Rust、Go 等多种语言的参考实现和社区支持 1。
Open-source developer Sindre Sorhus has released a draft specification for a new configuration file format called SOML, which stands for "Sindre's Objectively Marvelous Language" 1. The format is designed to combine the strictness of JSON with the readability of YAML and TOML, aiming to eliminate ambiguities caused by implicit type conversions and indentation dependencies 1. By determining data types through syntax rather than content, SOML seeks to address common parsing issues found in other formats 1.
A core principle of SOML is that the syntax explicitly defines the type of a value 1. For example, '123' is treated as a string while 123 is an integer, preventing scenarios where unquoted values like country: no might be incorrectly parsed as a boolean false in YAML 1. The format introduces native support for specific data types including dates (e.g., 2026-09-19), timestamps (e.g., 2026-09-19T14:00:00Z), and durations (e.g., 30s, 1h30m) 1. Structurally, SOML does not require top-level braces, omits quotes around keys unless they contain spaces, uses line breaks instead of commas, and supports both block comments (/* */) and line comments (#) 1.
To enhance security, SOML does not support aliases or tags, which mitigates risks associated with "YAML bombs," and it explicitly prohibits duplicate keys 1. The specification includes a unique canonical form to ensure consistency for hashing and signing purposes, accompanied by a compliance test suite containing approximately 1,000 cases 1. The project is currently in the draft stage under the MIT license, with reference implementations already available for JavaScript, Rust, and Go 1.
评论
还没有评论,欢迎留下第一条。