Changeset 58022
- Timestamp:
- 04/18/2024 03:15:50 AM (4 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r56550 r58022 197 197 $this->strings['fs_no_folder'] = __( 'Unable to locate needed folder (%s).' ); 198 198 199 199 200 $this->strings['download_failed'] = __( 'Download failed.' ); 200 201 $this->strings['installing_package'] = __( 'Installing the latest version…' ); … … 528 529 } 529 530 530 if ( empty( $source ) || empty( $destination ) ) { 531 if ( 532 ( ! is_string( $source ) || '' === $source || trim( $source ) !== $source ) || 533 ( ! is_string( $destination ) || '' === $destination || trim( $destination ) !== $destination ) 534 ) { 531 535 return new WP_Error( 'bad_request', $this->strings['bad_request'] ); 532 536 } -
trunk/tests/phpunit/tests/admin/wpUpgrader.php
r56992 r58022 138 138 'fs_no_themes_dir', 139 139 'fs_no_folder', 140 140 141 'download_failed', 141 142 'installing_package', … … 778 779 public function data_install_package_invalid_paths() { 779 780 return array( 780 'empty string' => array( 'path' => '' ),781 'empty string' => array( 'path' => '' ), 781 782 782 783 // Type checks. 783 'empty array' => array( 'path' => array() ), 784 '(int) 0' => array( 'path' => 0 ), 785 '(int) -0' => array( 'path' => -0 ), 786 '(float) 0.0' => array( 'path' => 0.0 ), 787 '(float) -0.0' => array( 'path' => -0.0 ), 788 '(bool) false' => array( 'path' => false ), 789 'null' => array( 'path' => null ), 784 'empty array' => array( 'path' => array() ), 785 'populated array' => array( 'path' => array( '/' ) ), 786 '(int) 0' => array( 'path' => 0 ), 787 '(int) -0' => array( 'path' => -0 ), 788 '(int) -1' => array( 'path' => -1 ), 789 '(int) 1' => array( 'path' => 1 ), 790 '(float) 0.0' => array( 'path' => 0.0 ), 791 '(float) -0.0' => array( 'path' => -0.0 ), 792 '(float) 1.0' => array( 'path' => 1.0 ), 793 '(float) -1.0' => array( 'path' => -1.0 ), 794 '(bool) false' => array( 'path' => false ), 795 '(bool) true' => array( 'path' => true ), 796 'null' => array( 'path' => null ), 797 'empty object' => array( 'path' => new stdClass() ), 798 'populated object' => array( 'path' => (object) array( '/' ) ), 799 800 // Ensures that `trim()` is run triggering an empty array. 801 'a string with spaces' => array( 'path' => ' ' ), 802 'a string with tabs' => array( 'path' => "\t\t" ), 803 'a string with new lines' => array( 'path' => "\n\n" ), 804 'a string with carriage returns' => array( 'path' => "\r\r" ), 805 806 // Ensure that strings with leading/trailing whitespace are invalid. 807 'a path with a leading space' => array( 'path' => ' /path' ), 808 'a path with a trailing space' => array( 'path' => '/path ' ), 809 'a path with a leading tab' => array( 'path' => "\t/path" ), 810 'a path with a trailing tab' => array( 'path' => "/path\t" ), 790 811 ); 791 812 } … … 1558 1579 1559 1580 /** 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1560 1606 * Tests that `WP_Upgrader::download_package()` returns a file with the 1561 1607 * package name in it.
Note: See TracChangeset
for help on using the changeset viewer.