Make WordPress Core


Ignore:
Timestamp:
03/01/2014 09:44:43 PM (11 years ago)
Author:
nacin
Message:

Strip backslashes, not just forward slashes, from untrailingslashit().

trailingslashit() will now remove any forward or backslashes from the end of a string before appending a forward slash.

props knutsp, willmot.
fixes #22267.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r27284 r27344  
    14831483 * Appends a trailing slash.
    14841484 *
    1485  * Will remove trailing slash if it exists already before adding a trailing
    1486  * 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.
    14871487 *
    14881488 * The primary use of this is for paths and thus should be used for paths. It is
     
    14901490 *
    14911491 * @since 1.2.0
    1492  * @uses untrailingslashit() Unslashes string if it was slashed already.
    14931492 *
    14941493 * @param string $string What to add the trailing slash to.
    14951494 * @return string String with trailing slash added.
    14961495 */
    1497 function trailingslashit($string) {
    1498     return untrailingslashit($string) . '/';
    1499 }
    1500 
    1501 /**
    1502  * Removes trailing slash if it exists.
     1496function trailingslashit( $string ) {
     1497    return untrailingslashit( $string ) . '/';
     1498}
     1499
     1500/**
     1501 * Removes trailing forward slashes and backslashes if they exist.
    15031502 *
    15041503 * The primary use of this is for paths and thus should be used for paths. It is
     
    15071506 * @since 2.2.0
    15081507 *
    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 */
     1511function untrailingslashit( $string ) {
     1512    return rtrim( $string, '/\\' );
    15141513}
    15151514
Note: See TracChangeset for help on using the changeset viewer.