Making WordPress.org

Changeset 14489


Ignore:
Timestamp:
07/24/2025 01:38:04 AM (10 months ago)
Author:
dd32
Message:

API: Trac helpers: Avoid fatals with invalid inputs.

Location:
sites/trunk/api.wordpress.org/public_html/dotorg/trac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/trac/oembed/index.php

    r11614 r14489  
    2525header( 'X-WP-Embed: true' );
    2626
    27 $url = wp_unslash( $_REQUEST['url'] ?? '' );
     27$url = $_REQUEST['url'] ?? '';
     28$url = is_string( $url ) ? wp_unslash( $url ) : '';
    2829
    2930header( 'Allow: GET' );
     
    3132
    3233if (
     34    ! $url ||
     35    'GET' !== $_SERVER['REQUEST_METHOD'] ||
    3336    // meta|core are the only tracs embedable.
    3437    // milestone|ticketgraph|ticket|changeset are the only endpoints allowable.
    35     ! preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>milestone|ticketgraph|ticket|changeset|query)([/?]|$)!i', $url, $m ) ||
    36     'GET' !== $_SERVER['REQUEST_METHOD']
     38    ! preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>milestone|ticketgraph|ticket|changeset|query)([/?]|$)!i', $url, $m )
    3739) {
    3840    header( 'HTTP/1.1 404 Not Found', true, 404 );
  • sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/index.php

    r11544 r14489  
    55require __DIR__ . '/functions.php';
    66
    7 $trac          = preg_replace( '![^a-z]!', '', $_GET['trac'] ?? '' );
     7$trac          = $_GET['trac'] ?? '';
     8$trac          = is_string( $trac ) ? $trac : '';
     9$trac          = preg_replace( '![^a-z]!', '', $trac );
    810$ticket        = intval( $_GET['ticket'] ?? 0 );
    911$author        = wp_unslash( $_GET['author'] ?? '' );
     12$author        = is_string( $author ) ? $author : '';
    1013$authenticated = ! empty( $_GET['authenticated'] ); // Longer caches for logged out requests.
    1114
Note: See TracChangeset for help on using the changeset viewer.