File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 2626 let _text = text || '' ;
2727
2828 const domParser = new DOMParser ( ) ;
29- const htmlDocument = domParser . parseFromString ( _text , 'text/html' ) ;
29+ const htmlDocument = domParser . parseFromString (
30+ _text ,
31+ 'text/html'
32+ ) ;
33+
34+ /*
35+ * This looks funny and appears to be a no-op, but it
36+ * enforces the escaping. How? when _read_ the `innerText`
37+ * property decodes character references, returning a raw
38+ * string. When _written_, however, it re-encodes to ensure
39+ * that the rendered text replicates what it’s given.
40+ *
41+ * See: https://github.com/WordPress/wordpress-develop/pull/10536#discussion_r2550615378
42+ */
3043 htmlDocument . body . innerText = htmlDocument . body . innerText || '' ;
3144
3245 // Return the text with stripped tags.
You can’t perform that action at this time.
0 commit comments