Ticket #5300: 5300.diff
File 5300.diff, 4.3 KB (added by , 5 years ago) |
---|
-
trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
181 181 ) ); 182 182 } 183 183 184 // Plugins need descriptions. 184 185 if ( ! $this->plugin['Description'] ) { 185 186 $error = __( 'Error: The plugin has no description.', 'wporg-plugins' ); 186 187 … … 192 193 ) ); 193 194 } 194 195 196 // Plugins need versions. 195 197 if ( ! $this->plugin['Version'] ) { 196 198 $error = __( 'Error: The plugin has no version.', 'wporg-plugins' ); 197 199 … … 203 205 ) ); 204 206 } 205 207 208 // Versions should be NUMBERS. 206 209 if ( preg_match( '|[^\d\.]|', $this->plugin['Version'] ) ) { 207 210 $error = __( 'Error: Plugin versions are expected to be numbers.', 'wporg-plugins' ); 208 211 … … 214 217 } 215 218 216 219 // Prevent duplicate URLs. 220 // This is part of how the API looks for updates, so having them different helps prevent conflicts. 217 221 if ( ! empty( $this->plugin['PluginURI'] ) && ! empty( $this->plugin['AuthorURI'] ) && $this->plugin['PluginURI'] == $this->plugin['AuthorURI'] ) { 218 222 $error = __( 'Error: Your plugin and author URIs are the same.', 'wporg-plugins' ); 219 223 … … 241 245 } 242 246 } 243 247 248 // Check for a valid readme. 244 249 $readme = $this->find_readme_file(); 245 // Check for a valid readme.246 250 if ( empty( $readme ) ) { 247 251 $error = __( 'Error: The plugin has no readme.', 'wporg-plugins' ); 248 252 … … 404 408 'wp-admin', 405 409 // Reserved names. 406 410 'jquery', 411 'wordpress', 412 // common submissions by people trying to upload locally. 413 'akismet-anti-spam', 407 414 'site-kit-by-google', 408 'wordpress',409 415 'yoast-seo', 410 416 ); 411 417 … … 423 429 'adsense-', 424 430 'advanced-custom-fields-', 425 431 'adwords-', 432 'akismet-', 426 433 'amazon-', 427 434 'android-', 428 435 'apple-', 436 'aws-', 437 'bbpress-', 429 438 'bing-', 439 'buddypress-', 430 440 'contact-form-7-', 431 441 'divi-', 432 442 'easy-digital-downloads-', … … 453 463 'wa-', 454 464 'whatsapp', 455 465 'whats-app', 456 'woocommerce', 466 'watson', 467 'windows-', 468 'woocommerce', // technically ending with '-for-woocommerce' is allowed. 469 'woo-commerce', 457 470 'woo-', 458 471 'wordpress', 472 'yahoo-', 459 473 'yoast', 460 474 'youtube-', 461 475 ); … … 462 476 463 477 // Domains from which exceptions would be accepted. 464 478 $trademark_exceptions = array( 465 'yoast.com' => array( 'yoast' ), 466 'automattic.com' => array( 'wordpress', 'woo', 'woocommerce' ), 479 'yoast.com' => array( 'yoast' ), 480 'automattic.com' => array( 'akismet', 'jetpack', 'wordpress', 'woo', 'woo-', 'woocommerce' ), 481 'facebook.com' => array( 'facebook', 'whatsapp', 'instagram' ), 482 'support.microsoft.com' => array( 'bing-', 'microsoft-' ), 483 'microsoft.com' => array( 'bing-', 'microsoft-' ), 467 484 ); 468 485 486 // Trademarks that are allowed as 'for-whatever' ONLY. 487 $for_use_exceptions = array( 488 'woocommerce', 489 ); 490 469 491 $has_trademarked_slug = false; 470 492 471 493 foreach ( $trademarked_slugs as $trademark ) { … … 482 504 } 483 505 } 484 506 507 // check for 'for-TRADEMARK' exceptions. 508 if ( false !== $has_trademarked_slug && in_array( $has_trademarked_slug, $for_use_exceptions ) && false !== strpos( $this->plugin_slug, '-for-' . $trademark ) ) { 509 // At this point we might be okay, but there's one more check. 510 $length = strlen( '-for-' . $trademark ); 511 $compare = substr_compare( $this->plugin_slug, '-for-' . $trademark, -$length, $length ); 512 513 if ( 0 === $compare ) { 514 // Yes the slug ENDS with 'for-TRADEMARK'. 515 $has_trademarked_slug = false; 516 } 517 } 518 485 519 // Get the user email domain. 486 520 $user_email_domain = explode( '@', wp_get_current_user()->user_email, 2 ); 487 521 488 522 // If email domain is on our list of possible exceptions, we have an extra check. 489 if ( array_key_exists( $user_email_domain[1], $trademark_exceptions ) ) {523 if ( false !== $has_trademarked_slug && array_key_exists( $user_email_domain[1], $trademark_exceptions ) ) { 490 524 // If $has_trademarked_slug is in the array for that domain, they can use the term. 491 525 if ( in_array( $has_trademarked_slug, $trademark_exceptions[ $user_email_domain[1] ] ) ) { 492 526 $has_trademarked_slug = false;