Skip to content

Commit

Permalink
post() will now strictly return $_POST variables, use the input() hel…
Browse files Browse the repository at this point in the history
…per to return general input values.
  • Loading branch information
daftspunk committed Feb 14, 2015
1 parent d855074 commit 952a7ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public static function evalHtmlArray($string)
{
$result = [$string];

if (strpbrk($string, '[]') === false)
return $result;

if (preg_match('/^([^\]]+)(?:\[(.+)\])+$/', $string, $matches)) {
if (count($matches) < 2)
return $result;
Expand Down
22 changes: 13 additions & 9 deletions src/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ function input($name = null, $default = null)
/*
* Array field name, eg: field[key][key2][key3]
*/
$keyParts = October\Rain\Support\Str::evalHtmlArray($name);
$dottedName = implode('.', $keyParts);
return Input::get($dottedName, $default);
$name = implode('.', Str::evalHtmlArray($name));
return Input::get($name, $default);
}
}

if (!function_exists('post'))
{
/**
* Identical function to input(), however may be restricted
* to $_POST values in future.
* Identical function to input(), however restricted to $_POST values.
*/
function post($name = null, $default = null)
{
return input($name, $default);
if ($name === null)
return $_POST;

/*
* Array field name, eg: field[key][key2][key3]
*/
$name = implode('.', Str::evalHtmlArray($name));
return array_get($_POST, $name, $default);
}
}

Expand All @@ -55,9 +60,8 @@ function get($name = null, $default = null)
/*
* Array field name, eg: field[key][key2][key3]
*/
$keyParts = October\Rain\Support\Str::evalHtmlArray($name);
$dottedName = implode('.', $keyParts);
return array_get($_GET, $dottedName, $default);
$name = implode('.', Str::evalHtmlArray($name));
return array_get($_GET, $name, $default);
}
}

Expand Down

0 comments on commit 952a7ee

Please sign in to comment.