Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

UPLC: Flat decoding accepts invalid UTF-8 in a string constant and drops a leading BOM

オープン 初心者向け
#696 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
backend

調査の方向性

UPLC.ts:652 の decodeData から始め、文字列定数の flat デコードテストを読んでください。TextDecoder が不正な UTF-8 と先頭の BOM をどのように扱うかを確認し、デコード時に不正なバイトが拒否され、BOM が保持されることを検証してください。スクリプトのバイト列を変更せずに両方のケースで往復でき、デコーダーのエラーが UPLCError として表面化すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug

fromFlatHex accepts a string constant that is not valid UTF-8, and it drops a leading byte order mark (BOM). Both change the script bytes on re-encode.

  • 010000490101ff0001 is (program 1.0.0 (con string ...)) holding the single byte ff. It decodes as "�" and re-encodes to 010000490103efbfbd0001. Plutus rejects it with "Input contains invalid UTF-8 data" (dUTF8, plutus-core/flat/src/PlutusCore/Flat/Decoder/Strict.hs:293-299 at 1.72.0.0).
  • The SDK encodes the string "A" as 010000490104efbbbf410001. Decoding those bytes returns "A", so the constant loses a character, and re-encoding gives 010000490101410001.

The cause is new TextDecoder().decode(bytes) in decodeData (UPLC.ts:652 on main), which replaces invalid bytes with U+FFFD and strips a BOM. new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }), with its TypeError turned into a UPLCError, matches Plutus.

The ledger rejects such a script, so a transaction carrying one fails before any script runs. The harm is on our side: applyParamsToScript re-encodes the script, so its bytes and hash change without an error. #694 is the same kind of problem for byte strings.

主要言語
TypeScript
スター
22
フォーク
35
平均マージ
19時間 9分
マージ済み PR(30日)
65

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

IntersectMBO/evolution-sdk のほかの issue

IntersectMBO/evolution-sdk の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。