Markup returned by `generate` or `format` callbacks runs in the editor when inserted as an inline binding
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
調査の方向性
Start by reading InlineBindingButton.tsx and InlineBindings.php, then trace how generate and format callback values reach inline bindings. The issue outlines several possible sanitization points and their tradeoffs, so the right behavior needs project familiarity. Done means untrusted callback markup cannot execute in the editor while the documented behavior and front end remain consistent.
索引モデルが issue の本文から書いたものです。
説明
Description
Values of text typed fields are sanitized by the field type (Sanitizer::sanitize_primitive_type), but the output of a generate callback, a format callback, the remote_data_blocks_query_response_metadata filter and html typed fields is not. The editor inserts the value of an inline binding as markup (InlineBindingButton.tsx sets innerHTML), so markup such as <img src="x" onerror="..."> in such a value runs in the editor session when an editor inserts the field. Saved posts keep the markup only for users with unfiltered_html.
Reproduction: register a block whose output schema has a string field with a generate callback returning <img src="x" onerror="document.title='script-ran'">, insert the field as an inline binding in a paragraph, and check the editor canvas document title.
It needs custom code that returns untrusted markup in a text typed field. The built-in integrations do not. Trunk behaves this way today. The output schema docs now say that callback output is not sanitized by the field type.
Options
- Filter the REST response with kses. Keeps formatting and matches the front end. Changes the response and the data saved in the post, depends on the site's allowed tags filter, alters text such as
1 < 2 and 3 > 2unless only real tags are filtered, leaves fragments for malformed markup, and mangled values can trip the existingdata-queryentity decoding problem (every inline field of the record then falls back on the front end). - Escape the value at inline insert. Nothing can run. Formatting from custom callbacks shows as literal tags in the editor, and the inline field's saved text is escaped, so visitors would see literal tags if the live fetch fails.
- Apply the declared field type's sanitizer to
generateandformatoutput. Cleanest rule, but a contract change for custom code that returns markup in text fields. - Sanitize in the editor (DOMPurify). Tried and dropped: it removed
data-queryfrom saved inline fields in some cases, changed rich text attributes for other blocks, and was bypassed by nested rich text.
Related
Values containing entity text such as " make every inline field of that record fall back on the front end, because InlineBindings.php decodes entities once before json_decode. That is a separate problem that already happens on trunk and has its own fix.
- 主要言語
- PHP
- スター
- 86
- フォーク
- 14
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 23
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Automattic/remote-data-blocks のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
Automattic/remote-data-blocks#879 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
Automattic/remote-data-blocks#878 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
Automattic/remote-data-blocks#821 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Automattic/remote-data-blocks#640 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
Automattic/remote-data-blocks#312 ·
メンテナーはふだん 1 日以内に返信
Automattic/remote-data-blocks の issue をすべて見る
似ている issue
-
Document lexicon.default.userconfig and lexicon.default.userconfig.enforced in config.sample.phpオープンenhancement feature: settings good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nextcloud/integration_openai#480 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
omeka/plugin-Contribution#84 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
recca0120/vscode-phpunit#620 ·
メンテナーはふだん 1 日以内に返信