We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0612d03 commit 84c2bd9Copy full SHA for 84c2bd9
1 file changed
src/js/_enqueues/wp/sanitize.js
@@ -26,7 +26,20 @@
26
let _text = text || '';
27
28
const domParser = new DOMParser();
29
- const htmlDocument = domParser.parseFromString( _text, 'text/html' );
+ 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
+ */
43
htmlDocument.body.innerText = htmlDocument.body.innerText || '';
44
45
// Return the text with stripped tags.
0 commit comments