Making WordPress.org

Changeset 5562


Ignore:
Timestamp:
06/13/2017 10:26:59 AM (8 years ago)
Author:
tellyworth
Message:

Plugin directory: strip non-latin characters from plugin slugs on upload. Props @SergeyBiryukov

Fixes #2821

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r5561 r5562  
    8484
    8585        // Determine the plugin slug based on the name of the plugin in the main plugin file.
    86         $this->plugin_slug = sanitize_title_with_dashes( $this->plugin['Name'] );
     86        $this->plugin_slug = remove_accents( $this->plugin['Name'] );
     87        $this->plugin_slug = preg_replace( '/[^a-z0-9 _.-]/i', '', $this->plugin_slug );
     88        $this->plugin_slug = sanitize_title_with_dashes( $this->plugin_slug );
     89
     90        if ( ! $this->plugin_slug ) {
     91            $error = __( 'The plugin has an unsupported name.', 'wporg-plugins' );
     92
     93            /* translators: %s: 'Plugin Name:' */
     94            return $error . ' ' . sprintf( __( 'Plugin names can only contain latin letters (A-z), numbers, spaces, and hyphens. Please change the %s line in your main plugin file and upload it again.', 'wporg-plugins' ),
     95                esc_html( $this->plugin['Name'] ),
     96                '<code>Plugin Name:</code>'
     97            );
     98        }
    8799
    88100        // Make sure it doesn't use a slug deemed not to be used by the public.
Note: See TracChangeset for help on using the changeset viewer.