Changeset 13865 for sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-bad-request.php
- Timestamp:
- 06/27/2024 07:34:58 AM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-bad-request.php
r13731 r13865 52 52 $query_vars[] = 'url'; 53 53 $query_vars[] = 'replytocom'; 54 $query_vars[] = 'tag_slug__and'; // Theme Directory has added this as a public query var. 54 55 55 56 // Assumption: WP::$public_query_vars will only ever contain non-array query vars. 56 // Assumption invalid. Some fields are valid. 57 $array_fields = [ 58 'post_type' => true, 59 'cat' => true, 60 'tag' => true, 57 // Assumption invalid. Some fields are valid as arrays. 58 // We'll limit these to a flat array, not nested. 59 $maybe_array_fields = [ 60 'post_type' => true, 61 'cat' => true, 62 'tag' => true, 63 'tag_slug__and' => true, 61 64 ]; 62 65 … … 81 84 82 85 foreach ( $query_vars as $field ) { 83 if ( isset( $vars[ $field ] ) ) { 84 if ( ! is_scalar( $vars[ $field ] ) && ! isset( $array_fields[ $field ] ) ) { 85 die_bad_request( "non-scalar $field in $ref" ); 86 if ( ! isset( $vars[ $field ] ) ) { 87 continue; 88 } 89 90 if ( isset( $maybe_array_fields[ $field ] ) && ! is_scalar( $vars[ $field ] ) ) { 91 if ( array_filter( $vars[ $field ], function( $item ) { return ! is_scalar( $item ); } ) ) { 92 die_bad_request( "non-scalar value in {$field}[] in $ref" ); 86 93 } 87 88 if ( isset( $must_be_num[ $field ] ) && ! empty( $vars[ $field ] ) && ! is_numeric( $vars[ $field ] ) ) {89 90 // Allow the `p` variable to contain `p=12345/`: https://bbpress.trac.wordpress.org/ticket/3424 91 if ( 'p' === $field && ( intval( $vars[ $field ] ) . '/' ===$vars[ $field ] ) ) {92 continue; 93 }94 95 die_bad_request( "non-numeric $field in $ref" );94 } else if ( ! is_scalar( $vars[ $field ] ) ) { 95 die_bad_request( "non-scalar $field in $ref" ); 96 } 97 98 if ( isset( $must_be_num[ $field ] ) && ! empty( $vars[ $field ] ) && ! is_numeric( $vars[ $field ] ) ) { 99 100 // Allow the `p` variable to contain `p=12345/`: https://bbpress.trac.wordpress.org/ticket/3424 101 if ( 'p' === $field && ( intval( $vars[ $field ] ) . '/' === $vars[ $field ] ) ) { 102 continue; 96 103 } 104 105 die_bad_request( "non-numeric $field in $ref" ); 97 106 } 98 107 }
Note: See TracChangeset
for help on using the changeset viewer.