Skip to content

Commit

Permalink
capture unsupported input formats so we know it when we miss something
Browse files Browse the repository at this point in the history
  • Loading branch information
WanWizard committed Sep 24, 2016
1 parent 7246147 commit 90c357e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions classes/input/instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,18 @@ protected function hydrate()
$this->input_xml = $php_input = \Security::clean(\Format::forge($php_input, 'xml')->to_array());
}

// handle raw formats
else
// unknown input format
elseif ($php_input and ! is_array($php_input))
{
// don't know how to handle it
throw new \DomainException('Don\'t know how to parse input of type: '.$content_type);
}

// store it as other input data as well
if ($this->method() == 'PUT' or $this->method() == 'PATCH' or $this->method() == 'DELETE')
$method = strtolower($this->method());
if ($method == 'put' or $method == 'patch' or $method == 'delete')
{
$this->{'input_'.strtolower($this->method())} = $php_input;
$this->{'input_'.$method} = $php_input;
}
}
}

7 comments on commit 90c357e

@it-can
Copy link
Contributor

@it-can it-can commented on 90c357e Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WanWizard I am getting these errors now with ajax post requests

Fatal error: Uncaught exception 'DomainException' with message 'Don't know how to parse input of type: application/x-www-form-urlencoded; charset=UTF-8' in /home/test/public_html/fuel/core/classes/input/instance.php:481
Stack trace: #0 /home/test/public_html/fuel/core/classes/input/instance.php(100): Fuel\Core\Input_Instance->hydrate() #1 /home/test/public_html/fuel/core/classes/input.php(49): Fuel\Core\Input_Instance->__construct() #2 /home/test/public_html/fuel/core/classes/input.php(67): Fuel\Core\Input::forge() #3 /home/test/public_html/fuel/core/classes/input.php(75): Fuel\Core\Input::instance() #4 /home/test/public_html/fuel/core/classes/session/driver.php(501): Fuel\Core\Input::__callStatic('post', Array) #5 /home/test/public_html/fuel/core/classes/session/driver.php(501): Fuel\Core\Input::post('', false) #6 /home/test/public_html/fuel/core/classes/session/file.php(74): Fuel\Core\Session_Driver->_get_cookie() #7 /home/test/public_html/fuel/core/classes/session.php(171): Fuel\Core in /home/test/public_html/fuel/core/classes/input/instance.php on line 481

@WanWizard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping for those. Thanks. How do you access the input from these posts? Because that bit of code hasn't changed, so if your "Content-Type" has always included a Charset, Input has never been able to decode the input?

@it-can
Copy link
Contributor

@it-can it-can commented on 90c357e Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use \Input::post('field'); in my controller, my ajax does a POST (via jquery $.post)

@WanWizard
Copy link
Member Author

@WanWizard WanWizard commented on 90c357e Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix pushed to remove the optional parameters from the content type. So you never use PATCH, PUT or DELETE?

@it-can
Copy link
Contributor

@it-can it-can commented on 90c357e Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in this project I think...

@it-can
Copy link
Contributor

@it-can it-can commented on 90c357e Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last commit seems to work

@WanWizard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the feedback.

Please sign in to comment.