apply_patch drops the BOM when line 1 is replaced, and write_file rewrites CRLF and BOM files as LF without a BOM
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- tooling
調査の方向性
まず src/main/tools/apply_patch.ts の applyHunks と src/main/tools/files.ts の write_file を確認し、続いて issue に記載されている回帰テスト apply_patch.test.ts と tools.test.ts を読みます。既存ファイルの BOM と改行コードがどのように扱われているか確認します。先頭行を置き換えても BOM が保持され、CRLF と BOM を含むファイルを上書きしても両方が保持され、回帰ケースが通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Found in the Oct 11 audit (at c5f5641). Follow-up to #246.
Where: src/main/tools/apply_patch.ts:133-157 (applyHunks); src/main/tools/files.ts:229-242 (write_file).
Cause:
- The BOM is part of line 1's text.
normalizeLoosetrims it, so-Write-Host …matches\uFEFFWrite-Host …, and the replacement comes entirely from the+line. The #246 fix keeps the BOM only when line 1 is a context line. write_filewritesBuffer.from(content)as given; unlikeapplyEditandapplyHunksit keeps neither line endings nor the BOM.
Reproduction (confirmed on Windows):
b.ps1=\uFEFFWrite-Host "héllo"\r\nline2\r\n, a patch replacing line 1 →Write-Host "hällo"\r\nline2\r\n(BOM gone).- Overwriting a BOM+CRLF file with
write_file→ LF only, no BOM.
Impact: Windows PowerShell 5.1 reads a .ps1 without a BOM as ANSI, so non-ASCII text becomes mojibake when the script runs; CRLF files show as entirely changed in diffs.
Fix: in applyHunks, add the BOM back when the original had one and the result does not. In write_file, when overwriting an existing file, convert to detectEol(before) and keep its BOM.
Regression test: "first line replaced in a BOM file" in apply_patch.test.ts; a CRLF+BOM overwrite in tools.test.ts.
- 主要言語
- TypeScript
- スター
- 2
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 2 日以内に返信
-
reproduced
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
anomalyco/opencode#62052 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
strapi/design-system#2084 ·
メンテナーはふだん 3 日以内に返信
-
check:passed streams:remove
難易度 1/5 1時間未満 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
OAuth documentation for GET /api/v2/users/me/ appears inconsistent with required global read scopeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信