Changeset 13720 for sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-bad-request.php
- Timestamp:
- 05/17/2024 02:09:30 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-bad-request.php
r12884 r13720 183 183 184 184 /** 185 * Detect invalid charsets to trackbacks. 186 * Hotfix for https://core.trac.wordpress.org/ticket/60261 187 */ 188 add_action( 'template_redirect', function() { 189 if ( ! is_trackback() ) { 190 return; 191 } 192 193 $charset = str_replace( array( ',', ' ' ), '', strtoupper( trim( $_POST['charset'] ?? '' ) ) ); 194 195 if ( function_exists( 'mb_list_encodings' ) && ! in_array( $charset, mb_list_encodings(), true ) ) { 196 die_bad_request( 'Invalid Charset' ); 197 } 198 } ); 199 200 /** 201 * Detect invalid requests to GlotPress 202 * 203 * Hotfix for https://github.com/GlotPress/GlotPress/pull/1835 204 */ 205 add_action( 'gp_init', function() { 206 $only_array_values = [ 'filter', 'sort' ]; 207 208 foreach ( $only_array_values as $query_var ) { 209 if ( isset( $_GET[ $query_var ] ) && ! is_array( $_GET[ $query_var ] ) ) { 210 if ( empty( $_GET[ $query_var ] ) ) { 211 // If it's not set to anything, just silently discard the value. 212 unset( $_GET[ $query_var ], $_REQUEST[ $query_var ] ); 213 continue; 214 } 215 216 die_bad_request( "non-array $query_var in GlotPress" ); 217 } 218 } 219 } ); 220 221 /** 185 222 * Die with a 400 Bad Request. 186 223 *
Note: See TracChangeset
for help on using the changeset viewer.