[wp-trac] [WordPress Trac] #35437: dot in permalinks

WordPress Trac noreply at wordpress.org
Wed Jan 13 06:49:04 UTC 2016


#35437: dot in permalinks
-------------------------+-----------------------------
 Reporter:  vk_code      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Permalinks   |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Just try to add dot in request uri (begin or end of any part) – it will
 return status 200, but should 404 or may be it should redirect to url
 without dots, otherwise it generates duplicate pages that is not so good.

 For example.
 Correct url is http://site.com/some/url/
 Let's try: http://site.com/.some/url/ – will return status 200 and open
 the correct page.

 The same behavior if:
 http://site.com/some./url/
 http://site.com/some/.url/
 http://site.com/some/url./

 Temporary solution in functions.php helpful for me:

 {{{#!php
 <?php
 function clear_uri($var) {
     global $clear_processed;

     $clear_processed = true;
     $str = trim($var, '.');

     if( $str[0] == '.' || $str[strlen($str)-1] == '.' )
         $str = clear_uri($str, '.');

     return $str;
 }

 $clear_processed = false;
 $parts = explode('/', trim($_SERVER['REQUEST_URI'], '/'));

 foreach($parts as $k => $s) {
     if( $s[0] == '.' || $s[strlen($s)-1] == '.' )
         $parts[$k] = clear_uri($s);
 }

 if( $clear_processed ) {
     $location = '/' . implode('/', $parts) . '/';
     header("Location: " . $location, true, 301);
     exit;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35437>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list