-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## WordPress's escape API enumerates what it ships\n\n`sanitize_text_field()` lives in `wp-includes/formatting.php`. The function dispatches to `_sanitize_text_fields( $str, false )`, whose body in WordPress 6.6 performs five transformations in this order. `wp_check_invalid_utf8()` strips bytes that fail UTF-8 validation. A `str_contains( $filtered, '<' )` branch invokes `wp_strip_all_tags()` and rewrites `<\\n` to `<`. A `preg_replace( '/[\\r\\n\\t ]+/', ' ', $filtered )` collapses runs of whitespace, newlines, and tabs to a single space. `trim()` strips leading and trailing whitespace. A `while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $matches ) )` loop removes percent-encoded sequences. The function returns the result through the `sanitize_text_field` filter.\n\nThe transformation set does not contain the backtick character. The set does not contain the open paren, the close paren, the comma, the hash sign, the semicolon, or any keyword the MySQL parser reads as syntax. The function's name encodes the threat model the WordPress core developers were thinking about when they wrote it: a visitor posting body text into a form field whose value will be rendered into an HTML page, where the dangerous tokens are the ones an HTML parser interprets. The body of `_sanitize_text_fields` is correct, complete behaviour for that threat model.\n\nWordPress's escape API enumerates the destinations the platform considers legal: `esc_html` for body text, `esc_attr` for attribute values, `esc_url` for `href`-bound URLs, `esc_js` for JavaScript-string content, `esc_textarea` for `