Making WordPress.org

Changeset 5247


Ignore:
Timestamp:
04/05/2017 04:30:11 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: When storing the list of plugin tags for a plugin, sanitize them for display uses.

See #2365

File:
1 edited

Legend:

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

    r5201 r5247  
    231231        $tagged_versions = SVN::ls( "https://plugins.svn.wordpress.org/{$plugin_slug}/tags/" ) ?: array();
    232232        $tagged_versions = array_map( function( $item ) {
    233             return rtrim( $item, '/' );
     233            $trimmed_item = rtrim( $item, '/' );
     234            if ( $trimmed_item == $item ) {
     235                // If attempting to trim `/` off didn't do anything, it was a file and we want to discard it.
     236                return null;
     237            }
     238
     239            // Prefix the 0 for plugin versions like 0.1
     240            if ( '.' == substr( $trimmed_item, 0, 1 ) ) {
     241                $trimmed_item = "0{$trimmed_item}";
     242            }
     243
     244            return $trimmed_item;
    234245        }, $tagged_versions );
     246
     247        // Strip out any of the before-found files which we set to NULL
     248        $tagged_versions = array_filter( $tagged_versions, function( $item ) {
     249            return ! is_null( $item );
     250        } );
    235251
    236252        // Not all plugins utilise `trunk`, some just tag versions.
Note: See TracChangeset for help on using the changeset viewer.