Markup returned by `generate` or `format` callbacks runs in the editor when inserted as an inline binding
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 86
- Fork
- 14
- Merge medio
- 1g 5h
- PR unite (30g)
- 23
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Automattic/remote-data-blocks
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Automattic/remote-data-blocks#879 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
Automattic/remote-data-blocks#878 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Automattic/remote-data-blocks#821 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Automattic/remote-data-blocks#640 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
Automattic/remote-data-blocks#312 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Automattic/remote-data-blocks
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
recca0120/vscode-phpunit#620 ·
I maintainer di solito rispondono entro 1 giorno
-
Validation rule generation for recursive Data objects is unbounded (O(payload depth))Forse già presa @irfanm96 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
spatie/laravel-data#1226 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno