Changeset 65875
- Timestamp:
- 12/03/2026 04:25:13 AM (16 hours ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/kses.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/kses.php
r65866 r65875 2019 2019 2020 2020 if ( $is_special_atomic_element ) { 2021 if ( 'TITLE' === $token_name || 'TEXTAREA' === $token_name ) { 2022 /* 2023 * RCDATA nodes can be safely escaped, but this must be 2024 * done after enqueuing the update to avoid double-escaping. 2025 */ 2026 $tag_maker->set_modifiable_text( $text ); 2027 $tag_maker->lexical_updates['modifiable text']->text = strtr( 2028 $tag_maker->lexical_updates['modifiable text']->text, 2029 array( 2030 "\x00" => "\u{FFFD}", 2031 "\r" => '
', 2032 ) 2033 ); 2034 } elseif ( ! self::contains_a_block_delimiter( $text ) ) { 2035 // Other nodes not containing a block delimiter are safe. 2036 $tag_maker->set_modifiable_text( $text ); 2037 } else { 2038 /* 2039 * But RAWTEXT and SCRIPT cannot be generally escaped, so reject 2040 * updates which would include something that could be misparsed 2041 * as a block comment delimiter. 2042 */ 2043 $tag_maker->set_modifiable_text( '' ); 2021 switch ( $token_name ) { 2022 case 'IFRAME': 2023 /* 2024 * IFRAME contents are ignored, so there is no reason to allow 2025 * them from untrusted inputs. 2026 */ 2027 $tag_maker->set_modifiable_text( '' ); 2028 break; 2029 2030 case 'TEXTAREA': 2031 case 'TITLE': 2032 /* 2033 * RCDATA nodes can be safely escaped, but this must be 2034 * done after enqueuing the update to avoid double-escaping. 2035 */ 2036 $tag_maker->set_modifiable_text( $text ); 2037 $tag_maker->lexical_updates['modifiable text']->text = strtr( 2038 $tag_maker->lexical_updates['modifiable text']->text, 2039 array( 2040 "\x00" => "\u{FFFD}", 2041 "\r" => '
', 2042 ) 2043 ); 2044 break; 2045 2046 case 'NOEMBED': 2047 case 'NOFRAMES': 2048 case 'XMP': 2049 /* 2050 * These elements are obsolete and their contents are not 2051 * unescaped; therefore make a visual change to prevent 2052 * downstream parsers from interpreting content as markup. 2053 * The alternative is rejecting the elements entirely, which 2054 * is the default behavior unless they are specifically allowed. 2055 * 2056 * Replacing angle brackets with U+27E8 and U+27E9 is a practical 2057 * content degradation that will mostly preserve the contents 2058 * perceptually while retaining as much as is safely possible. 2059 */ 2060 $text = strtr( 2061 $text, 2062 array( 2063 '<' => '⟨', 2064 '>' => '⟩', 2065 ) 2066 ); 2067 $tag_maker->set_modifiable_text( $text ); 2068 break; 2069 2070 default: 2071 if ( self::contains_a_block_delimiter( $text ) ) { 2072 /* 2073 * Reject special atomic elements whose contents contain the syntax 2074 * for a block comment delimiter to prevent accidental parses. There 2075 * is no reliable way to escape their content, so rejecting it is a 2076 * more fitting approach for untrusted inputs. 2077 */ 2078 $tag_maker->set_modifiable_text( '' ); 2079 } else { 2080 // Otherwise consider the contents safe to pass through. 2081 $tag_maker->set_modifiable_text( $text ); 2082 } 2044 2083 } 2045 2084 }
Note:
See TracChangeset
for help on using the changeset viewer.