Changeset 27344
- Timestamp:
- 03/01/2014 09:44:43 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r27284 r27344 1483 1483 * Appends a trailing slash. 1484 1484 * 1485 * Will remove trailing slash if it exists already before adding a trailing1486 * slash. This prevents double slashing a string or path.1485 * Will remove trailing forward and backslashes if it exists already before adding 1486 * a trailing forward slash. This prevents double slashing a string or path. 1487 1487 * 1488 1488 * The primary use of this is for paths and thus should be used for paths. It is … … 1490 1490 * 1491 1491 * @since 1.2.0 1492 * @uses untrailingslashit() Unslashes string if it was slashed already.1493 1492 * 1494 1493 * @param string $string What to add the trailing slash to. 1495 1494 * @return string String with trailing slash added. 1496 1495 */ 1497 function trailingslashit( $string) {1498 return untrailingslashit( $string) . '/';1499 } 1500 1501 /** 1502 * Removes trailing slash if it exists.1496 function trailingslashit( $string ) { 1497 return untrailingslashit( $string ) . '/'; 1498 } 1499 1500 /** 1501 * Removes trailing forward slashes and backslashes if they exist. 1503 1502 * 1504 1503 * The primary use of this is for paths and thus should be used for paths. It is … … 1507 1506 * @since 2.2.0 1508 1507 * 1509 * @param string $string What to remove the trailing slash from.1510 * @return string String without the trailing slash .1511 */ 1512 function untrailingslashit( $string) {1513 return rtrim( $string, '/');1508 * @param string $string What to remove the trailing slashes from. 1509 * @return string String without the trailing slashes. 1510 */ 1511 function untrailingslashit( $string ) { 1512 return rtrim( $string, '/\\' ); 1514 1513 } 1515 1514 -
trunk/src/wp-includes/functions.php
r27272 r27344 1456 1456 1457 1457 if ( $temp ) 1458 return trailingslashit( rtrim( $temp, '\\' ));1458 return trailingslashit( $temp ); 1459 1459 1460 1460 if ( function_exists('sys_get_temp_dir') ) { 1461 1461 $temp = sys_get_temp_dir(); 1462 1462 if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) 1463 return trailingslashit( rtrim( $temp, '\\' ));1463 return trailingslashit( $temp ); 1464 1464 } 1465 1465 1466 1466 $temp = ini_get('upload_tmp_dir'); 1467 1467 if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) 1468 return trailingslashit( rtrim( $temp, '\\' ));1468 return trailingslashit( $temp ); 1469 1469 1470 1470 $temp = WP_CONTENT_DIR . '/'; -
trunk/tests/phpunit/tests/formatting/Slashit.php
r25002 r27344 22 22 } 23 23 24 /** 25 * @ticket 22267 26 */ 27 function test_removes_trailing_backslashes() { 28 $this->assertEquals("a", untrailingslashit("a\\")); 29 $this->assertEquals("a", untrailingslashit("a\\\\\\\\")); 30 } 31 32 /** 33 * @ticket 22267 34 */ 35 function test_removes_trailing_mixed_slashes() { 36 $this->assertEquals("a", untrailingslashit("a/\\")); 37 $this->assertEquals("a", untrailingslashit("a\\/\\///\\\\//")); 38 } 39 24 40 function test_adds_trailing_slash() { 25 41 $this->assertEquals("a/", trailingslashit("a")); … … 29 45 $this->assertEquals("a/", trailingslashit("a/")); 30 46 } 47 48 /** 49 * @ticket 22267 50 */ 51 function test_converts_trailing_backslash_to_slash_if_one_exists() { 52 $this->assertEquals("a/", trailingslashit("a\\")); 53 } 31 54 }
Note: See TracChangeset
for help on using the changeset viewer.