- Timestamp:
- 07/29/2026 06:33:11 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/trac/oembed/index.php
r14530 r15019 11 11 * 12 12 * Can be enabled on a site by adding: 13 * - wp_oembed_add_provider( '#https://(meta|core)\.trac\.wordpress .org/.*#', 'https://api.wordpress.org/dotorg/trac/oembed/?api_key=...');13 * - wp_oembed_add_provider( '#https://(meta|core)\.trac\.wordpress\.org/.*#', 'https://api.wordpress.org/dotorg/trac/oembed/?api_key=...', true ); 14 14 * 15 15 * oEmbed Discovery is not enabled, as although adding the tag to trac is possible, it requires inline Javascript. … … 25 25 header( 'X-WP-Embed: true' ); 26 26 27 $url = $_ REQUEST['url'] ?? '';27 $url = $_GET['url'] ?? ''; 28 28 $url = is_string( $url ) ? wp_unslash( $url ) : ''; 29 29 30 30 header( 'Allow: GET' ); 31 31 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s \G\M\T', time() + HOUR_IN_SECONDS ), true ); 32 33 // meta|core are the only tracs embedable. 34 $allowed_hosts = [ 35 'core.trac.wordpress.org', 36 'meta.trac.wordpress.org', 37 ]; 32 38 33 39 if ( 34 40 ! $url || 35 41 'GET' !== $_SERVER['REQUEST_METHOD'] || 36 // meta|core are the only tracs embedable. 37 // milestone|ticketgraph|ticket|changeset are the only endpoints allowable. 38 ! ( 39 preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>ticket|changeset)/\d+$!i', $url, $m ) || 40 preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>query)[?].+$!i', $url, $m ) || 41 preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>milestone)/[a-z0-9.]+[ ]?[a-z0-9.]*$!i', $url, $m ) || 42 preg_match( '!^(?P<baseurl>https://(?P<trac>meta|core).trac.wordpress.org/)(?P<type>ticketgraph)([?]component=[^&]+)?$!i', $url, $m ) 43 ) 42 ! in_array( strtolower( (string) wp_parse_url( $url, PHP_URL_HOST ) ), $allowed_hosts, true ) 44 43 ) { 44 header( 'HTTP/1.1 404 Not Found', true, 404 ); 45 die(); 46 } 47 48 // milestone|ticketgraph|ticket|changeset are the only endpoints allowable. 49 $trac_baseurl = '^(?P<baseurl>https://(?P<trac>meta|core)\.trac\.wordpress\.org/)'; 50 $allowed_urls = [ 51 '!' . $trac_baseurl . '(?P<type>ticket|changeset)/\d+$!iD', 52 '!' . $trac_baseurl . '(?P<type>query)[?].+$!iD', 53 '!' . $trac_baseurl . '(?P<type>milestone)/[a-z0-9.]+[ ]?[a-z0-9.]*$!iD', 54 '!' . $trac_baseurl . '(?P<type>ticketgraph)([?]component=[^&]+)?$!iD', 55 ]; 56 57 $m = []; 58 foreach ( $allowed_urls as $allowed_url ) { 59 if ( preg_match( $allowed_url, $url, $m ) ) { 60 break; 61 } 62 } 63 64 if ( ! $m ) { 45 65 header( 'HTTP/1.1 404 Not Found', true, 404 ); 46 66 die(); … … 117 137 die(); 118 138 } 139 140 // The remainder of this request outputs the HTML document displayed within the iframe. 141 header( 'Content-Type: text/html; charset=UTF-8' ); 142 header( 'X-Content-Type-Options: nosniff' ); 119 143 120 144 $cache_key = sha1( $url );
Note:
See TracChangeset
for help on using the changeset viewer.