summaryrefslogtreecommitdiff
path: root/kohana/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'kohana/helpers')
-rw-r--r--kohana/helpers/form.php4
-rw-r--r--kohana/helpers/html.php2
-rw-r--r--kohana/helpers/valid.php13
3 files changed, 15 insertions, 4 deletions
diff --git a/kohana/helpers/form.php b/kohana/helpers/form.php
index 30753f1e..5162a1ad 100644
--- a/kohana/helpers/form.php
+++ b/kohana/helpers/form.php
@@ -241,6 +241,7 @@ class form_Core {
*/
public static function dropdown($data, $options = NULL, $selected = NULL, $extra = '')
{
+
if ( ! is_array($data))
{
$data = array('name' => $data);
@@ -266,6 +267,9 @@ class form_Core {
// Key should always be a string
$key = (string) $key;
+ // Selected must always be a string
+ $selected = (string) $selected;
+
if (is_array($val))
{
$input .= '<optgroup label="'.$key.'">'."\n";
diff --git a/kohana/helpers/html.php b/kohana/helpers/html.php
index b11ea755..d1f09612 100644
--- a/kohana/helpers/html.php
+++ b/kohana/helpers/html.php
@@ -307,7 +307,7 @@ class html_Core {
$length = strlen($suffix);
- if (substr_compare($href, $suffix, -$length, $length, FALSE) !== 0)
+ if ( $length > 0 AND substr_compare($href, $suffix, -$length, $length, FALSE) !== 0)
{
// Add the defined suffix
$href .= $suffix;
diff --git a/kohana/helpers/valid.php b/kohana/helpers/valid.php
index d71dbcae..3d3206c8 100644
--- a/kohana/helpers/valid.php
+++ b/kohana/helpers/valid.php
@@ -87,10 +87,12 @@ class valid_Core {
* @param boolean allow IPv6 addresses
* @return boolean
*/
- public static function ip($ip, $ipv6 = FALSE)
+ public static function ip($ip, $ipv6 = FALSE, $allow_private = FALSE)
{
- // Do not allow private and reserved range IPs
+ // By default do not allow private and reserved range IPs
$flags = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
+ if ($allow_private === TRUE)
+ $flags = FILTER_FLAG_NO_RES_RANGE;
if ($ipv6 === TRUE)
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flags);
@@ -264,12 +266,17 @@ class valid_Core {
/**
* Checks whether a string is a valid number (negative and decimal numbers allowed).
*
+ * @see Uses locale conversion to allow decimal point to be locale specific.
+ * @see http://www.php.net/manual/en/function.localeconv.php
+ *
* @param string input string
* @return boolean
*/
public static function numeric($str)
{
- return (is_numeric($str) AND preg_match('/^[-0-9.]++$/D', (string) $str));
+ // Use localeconv to set the decimal_point value: Usually a comma or period.
+ $locale = localeconv();
+ return (preg_match('/^[-0-9'.$locale['decimal_point'].']++$/D', (string) $str));
}
/**