Make WordPress Core


Ignore:
Timestamp:
03/01/2014 09:44:43 PM (10 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/tests/phpunit/tests/formatting/Slashit.php

    r25002 r27344  
    2222    }
    2323
     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
    2440    function test_adds_trailing_slash() {
    2541        $this->assertEquals("a/", trailingslashit("a"));
     
    2945        $this->assertEquals("a/", trailingslashit("a/"));
    3046    }
     47
     48    /**
     49     * @ticket 22267
     50     */
     51    function test_converts_trailing_backslash_to_slash_if_one_exists() {
     52        $this->assertEquals("a/", trailingslashit("a\\"));
     53    }
    3154}
Note: See TracChangeset for help on using the changeset viewer.