Making WordPress.org

Changeset 13016


Ignore:
Timestamp:
12/06/2023 12:17:52 AM (16 months ago)
Author:
dd32
Message:

Plugin Directory: Import: Do not import plugins containing invalid Update URI headers.

See #5747

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r12979 r13016  
    8686        $current_stable_tag = get_post_meta( $plugin->ID, 'stable_tag', true ) ?: 'trunk';
    8787        $touches_stable_tag = (bool) array_intersect( [ $stable_tag, $current_stable_tag ], $svn_changed_tags );
     88
     89        // Validate various headers:
     90
     91        /*
     92         * Check to see if the plugin is using the `Update URI` header.
     93         *
     94         * Plugins on WordPress.org should NOT use this header, but we do accept some URI formats for it in the API,
     95         * so those are allowed to pass here.
     96         * Any documentation suggesting that a WordPress.org hosted plugin should use this header is incorrect.
     97         */
     98        if ( $headers->UpdateURI ) {
     99            $update_uri_valid = preg_match( '!^(https?://)?(wordpress.org|w.org)/plugins?/(?P<slug>[^/]+)/?$!i', $headers->UpdateURI, $update_uri_matches );
     100            if ( ! $update_uri_valid || $update_uri_matches['slug'] !== $plugin_slug ) {
     101                throw new Exception( 'Invalid Update URI header detected: ' . $headers->UpdateURI );
     102            }
     103        }
    88104
    89105        // Release confirmation
Note: See TracChangeset for help on using the changeset viewer.