I'm testing my Zend Framework application using Selenium and PHPUnit. I've got a test that must open a URL that consists of an encoded URL.
$redirectToLocation = urlencode('/myothercontroller/action') // %2Fmyothercontroller%2Faction $this->openAndWait('/controller/action/thenRedirectTo/' . $redirectToLocation)
However when I run my test, the browser attempted opening the decoded URL:
What must i caused by get selenium to spread out the encoded URL?
Update: Really...works out selenium does it's job, however it appears as though Apache is decoding the URL before it reaches the controller:
The asked for URL /controller/action/thenRedirectTo//myothercontroller/action wasn't available on this server.
How must i fix this issue?
Update: Here is a whole conversation comparable problem that I am getting: http://old.nabble.com/URL-Encoding-td18850769.html. Their workaround ended up being to base64 scribe the url, but that is not adequate enough for me personally. I might make use of this solution for the short term, but I wish to know what's the source of the problem, in order to avoid it.
Update: I've got a co-worker who thinks there might be an issue with the way in which Zend Framework is routing the request. Do you consider that may be?
It is really an Apache "feature". Encoded slashes are instantly decoded and delivered to the applying (php). Therefore it's acknowledged as one lengthy uri rather than an uri by having an encoded uri as parameter.
Nonetheless, you can turn this off, by utilizing
AllowEncodedSlashes On inside your configuration. More details in the Apache manual. Please be aware the context of the directive is server config and virtual host which means you cannot put it inside a .htaccess file.
Interesting problem. I have personally didn't have any problems passing another URL inside a query string, i.e. /controller/action/thenRedirectTo?q=%2Fmyothercontroller%2Faction , however i haven't used Apache inside a very long time, and that is not quite what you are attempting to do.
One possible solution might be double url encoding it.
$redirectToLocation = urlencode(urlencode('/myothercontroller/action')) $this->openAndWait('/controller/action/thenRedirectTo/' . $redirectToLocation)
Possibly Apache is only going to url decode it one level.
I have experienced this behavior before also it was mod_rewrite which was doing the decoding. So far as I understand the only method to circumvent it's urlencode the area of the request URL that must preserve special figures two times.
You need to set your mod_rewrite in debug mode in Apache and check out what he is doing:
RewriteEngine on RewriteLog /tmp/rewrite.log RewriteLogLevel 9
and show us your ZF rewrite rules. the correct answer is certainly base on % the competly decoded url. We're able to attempt to rework it with %, the non-decoded url. The very best factor could be dealing with % only for the best controller.
Another solution might be using base64 encoding around the url, to ensure that mod_rewrite and then any other tools would not catch it as being an url information.
Another factor to check may be the [B] on mod_rewrite, as described here : How you can scribe special figures using mod_rewrite & Apache? . However I question is would wouldn't break the rewrite rule.
It appears such as this Zend Framwork problem pertains to your condition. To ensure open Zend/Controller/Request/Http.php and take away the urldecode function calls but keep your variables in position and retest your code.