Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

SyntaxError for files with wrong encoding

未关闭
#517 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
ruby
领域
tooling

调研方向

从 Psych.safe_load 和 psych.rb:456 中报告的解析调用开始,然后使用附加的 example_file.txt 重现失败,并检查其编码。该 issue 没有指定测试或明确的验收条件;要完成此 issue,需要就非 UTF-8 输入的行为达成一致,并为该示例添加回归检查。

由索引模型根据 Issue 内容生成。

描述

I have multiple files that just look fine with editors (gedit, sublime, vim) but produce the following error message when loaded by Psych:

Psych.safe_load(file)
/usr/local/lib/ruby/3.0.0/psych.rb:456:in `parse': (<unknown>): invalid trailing UTF-8 octet at line 1 column 1 (Psych::SyntaxError)

A file example can be found here (renamed as attaching a .yaml file is not supported). I am not that familiar with character encoding, but the file seems to get interpreted as UTF-8 while it actually isn't. isutf8 returns metal_copper (1).yaml: line 87, char 12, byte 1497: After a first byte between E1 and EC, expecting the 2nd byte between 80 and BF. on the file example.

I do not know how editor software today handle this topic, but it sure would be desirable to have Psych parse files in the way as shown in common editors. From googling the error message it seems I am not the only one who had problems with that and it seem to produce problem now and then for users/project that use Psych.

主要语言
Ruby
星标
597
派生
223
平均合并
14 分钟
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/psych 的其他 Issue

查看 ruby/psych 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。