Question

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..'
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top