diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-05 12:43:25 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-05 12:43:25 +0100 |
commit | 193ec9693b642cf53a8ff7c2679f6a3c433abbb8 (patch) | |
tree | 6c9519bf9207dcbbd18e336a1a5dfb5252339220 /system/helpers | |
parent | 8741dda98f2cf4be982ce0cb4f6f798d2b53c0a9 (diff) | |
parent | 2baae203864cecd6f7c92b244c28dd18e0051d2c (diff) |
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop-issue-499
Diffstat (limited to 'system/helpers')
-rw-r--r-- | system/helpers/form_helper.php | 5 | ||||
-rw-r--r-- | system/helpers/url_helper.php | 34 |
2 files changed, 17 insertions, 22 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index bed2cb297..6efef2324 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -22,7 +22,6 @@ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 - * @filesource */ // ------------------------------------------------------------------------ @@ -72,8 +71,8 @@ if ( ! function_exists('form_open')) $form = '<form action="'.$action.'"'._attributes_to_string($attributes, TRUE).">\n"; - // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites - if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"'))) + // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites + if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"'))) { $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 2cbcd9dbf..3f0fef58e 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -470,39 +470,35 @@ if ( ! function_exists('prep_url')) * Create URL Title * * Takes a "title" string as input and creates a - * human-friendly URL string with either a dash - * or an underscore as the word separator. + * human-friendly URL string with a "separator" string + * as the word separator. * * @access public * @param string the string - * @param string the separator: dash, or underscore + * @param string the separator * @return string */ if ( ! function_exists('url_title')) { - function url_title($str, $separator = 'dash', $lowercase = FALSE) + function url_title($str, $separator = '-', $lowercase = FALSE) { if ($separator === 'dash') { - $search = '_'; - $replace = '-'; + $separator = '-'; } - else + else if ($separator == 'underscore') { - $search = '-'; - $replace = '_'; + $separator = '_'; } + + $q_separator = preg_quote($separator); $trans = array( - '&\#\d+?;' => '', - '&\S+?;' => '', - '\s+' => $replace, - '[^a-z0-9\-\._]' => '', - $replace.'+' => $replace, - $replace.'$' => $replace, - '^'.$replace => $replace, - '\.+$' => '' - ); + '&.+?;' => '', + '[^a-z0-9 _-]' => '', + '\s+' => $separator, + '('.$q_separator.')+' => $separator + ); $str = strip_tags($str); foreach ($trans as $key => $val) @@ -515,7 +511,7 @@ if ( ! function_exists('url_title')) $str = strtolower($str); } - return trim(trim(stripslashes($str)), $replace); + return trim(trim($str, $separator)); } } |