0

I got a weird problem with CodeIgniter's URI segment system.

When I have this URL:

http://www.mywebsite.com/forums/category_name/forum_name/topic_name.. (yes, the name has two dots)

Now I do this in PHP:

$topic = $this->uri->segment(4);
>>> echo $topic: 'topic_name..'

This works perfectly. But here comes the weirdness.. When I append a reply to the URL like this:

http://www.mywebsite.com/forums/category_name/forum_name/topic_name../reply

Now I do the PHP code again:

$topic = $this->uri->segment(4);
>>> echo $topic: 'topic_name '

As you can see it suddenly replaces my ".." with " " (one space, why not even two?).

Does anyone have any idea if the URI segment method might maybe sanitize something when I add a segment after one with dots ("."). The odd thing is when I manually fix the URL with a space behind it, it works again because after the trim() it still has the ".."'s left, where CodeIgniter didn't seem to touch them this time:

http://www.mywebsite.com/forums/category_name/forum_name/topic_name..%20/reply

$topic = $this->uri->segment(4);
> echo $topic: 'topic_name.. '
>>> echo trim($topic): 'topic_name..'
  • why decided to use dots in url? an possible alternative is short urls – Gntem Aug 05 '12 at 14:45
  • Well, I'm working with pretty-URL's. It works great so far. I seem to have most illegal characters covered with substitute characters. The URL should allow dots, so I'm just trying to figure out what CodeIgniter is doing wrong here. –  Aug 05 '12 at 15:05

1 Answers1

1

See below url:-

URI Class in CodeIgniter

The URI Class provides functions that help you retrieve information from your URI strings. If you use URI routing, you can also retrieve information about the re-routed segments.

http://codeigniter.com/user_guide/libraries/uri.html

Read this

I believe what is happening is that your server is using ./index.php as a 403. Adding “...” to the URI will result in one of two things happening.

1) The browser will try to change the folder handle and go up one or two directories

2) In the case of Apache Web Server “(20024)The given path is misformatted or contained invalid characters”

I would not recommend placing dots in the URI unless it is for the url suffix and then only one dot is required.

Abid Hussain
  • 7,724
  • 3
  • 35
  • 53