Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joomla Get/POST parameters ignoring white space in string

I am using Joomla 3.4. And I am using standard Joomla way to GET parameters. let's assume url contains signup?company=ZITO%20MEDIA,%20LP

According Joomla Standard code

$config = new JConfig();
$jinput = JFactory::getApplication()->input;
echo $jinput->get->get('company');

The result: ZITOMEDIALP

But if I change the code to standard php code

echo $_GET['company'];

The result: ZITO MEDIA, LP

I want to use joomla code since I working on joomla project but this is not what I want.

any ideas? and it happens to POST variables as well.

like image 697
Georgi Kovachev Avatar asked Jan 07 '23 20:01

Georgi Kovachev


2 Answers

According to the documentation, JInput by default applies the "cmd" filter which basically strips off whatever is not a-z.

You should apply the desired filter, e.g. "int", "string", "word", ... with this syntax:

$jinput->get('varname', 'default_value', 'filtername'); 

There is also a shorthand method for most of the filters, for example the following two lines of code are equivalent:

$jinput->get('varname', 'default_value', 'string');
$jinput->getString('varname', 'default_value');
like image 103
Francesco Abeni Avatar answered Jan 15 '23 19:01

Francesco Abeni


change

$jinput = JFactory::getApplication()->input;
echo $jinput->get->get('company');

to

$jinput = JFactory::getApplication()->input;
echo $jinput->getString('company', 'default_value');

use a default value as well in order to be able to handle the case of a missing parameter.

like image 43
JoomlaEvolved Development Avatar answered Jan 15 '23 20:01

JoomlaEvolved Development