Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rawurldecode request params #630

Closed
kohamkohane opened this issue Aug 4, 2015 · 3 comments
Closed

rawurldecode request params #630

kohamkohane opened this issue Aug 4, 2015 · 3 comments

Comments

@kohamkohane
Copy link

Please add rawurldecode to function param() in Kohana/Request. In KO 3.3.3 rawurlencode was added to function uri() in Kohana/Route. I suggest to add rawurldecode when we read these params.

public function param($key = NULL, $default = NULL)
{
    if ($key === NULL)
    {
        // Return the full array
        return $this->_params;
    }

    return isset($this->_params[$key]) ? $this->_params[$key] : $default; // THIS SHOULD BE DECODED
}
@enov
Copy link
Contributor

enov commented Aug 11, 2015

Hi there @kohamkohane, I am sorry to reply late.

Decoding the URL is the job of the web server. Just did a little test on this on a vanilla Kohana application:

  • Changed the action_index of Controller_Welcome to:
    $this->response->body($this->request->param('id'));
  • Called the application with this URL:
    http://kohana.dev/index.php/welcome/index/first%20second

received first second with a space between first and second.

I believe you need to rawurldecode only if the URL is not yet processed by the web server (if the URL was retrieved from a database, for example).

Let me know if this settles it.

@kohamkohane
Copy link
Author

You are right, but it does not work with internal requests. Then params are not decoded. Maybe the best solution for this issue is deocding URL somewhere in internal requests processing?

@enov
Copy link
Contributor

enov commented Aug 13, 2015

internal requests

😮 Exactly.

This is how I reproduced the bug: fresh Kohana application, changed Controller_Welcome to:

class Controller_Welcome extends Controller {

    public function action_index()
    {
        $this->response->body(Request::factory('welcome/internal/first%20second')->execute());
    }

    public function action_internal()
    {
        echo $this->request->param('id');
    }
}

and called the application from the browser: http://kohana.dev/index.php/welcome/index.

I got: first%20second

Maybe the best solution for this issue is deocding URL somewhere in internal requests processing

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants