Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed Jun 16, 2009
1 parent 08f36d7 commit a5bf55d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 58 deletions.
6 changes: 3 additions & 3 deletions core/authentication_api.php
Expand Up @@ -357,7 +357,7 @@ function auth_does_password_match( $p_user_id, $p_test_password ) {

# Check for migration to another login method and test whether the password was encrypted
# with our previously insecure implemention of the CRYPT method
if(( $t_login_method != $t_configured_login_method ) || (( CRYPT == $t_configured_login_method ) && substr( $t_password, 0, 2 ) == substr( $p_test_password, 0, 2 ) ) ) {
if(( $t_login_method != $t_configured_login_method ) || (( CRYPT == $t_configured_login_method ) && utf8_substr( $t_password, 0, 2 ) == utf8_substr( $p_test_password, 0, 2 ) ) ) {
user_set_password( $p_user_id, $p_test_password, true );
}

Expand Down Expand Up @@ -407,7 +407,7 @@ function auth_process_plain_password( $p_password, $p_salt = null, $p_method = n
}

# cut this off to PASSLEN cahracters which the largest possible string in the database
return substr( $t_processed_password, 0, PASSLEN );
return utf8_substr( $t_processed_password, 0, PASSLEN );
}

/**
Expand All @@ -421,7 +421,7 @@ function auth_generate_random_password( $p_email ) {
$t_val = mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() );
$t_val = md5( $t_val );

return substr( $t_val, 0, 12 );
return utf8_substr( $t_val, 0, 12 );
}

/**
Expand Down
8 changes: 4 additions & 4 deletions core/file_api.php
Expand Up @@ -151,7 +151,7 @@ function file_can_delete_bug_attachments( $p_bug_id ) {
function file_get_icon_url( $p_display_filename ) {
$t_file_type_icons = config_get( 'file_type_icons' );

$ext = strtolower( file_get_extension( $p_display_filename ) );
$ext = utf8_strtolower( file_get_extension( $p_display_filename ) );
if( is_blank( $ext ) || !isset( $t_file_type_icons[$ext] ) ) {
$ext = '?';
}
Expand All @@ -170,7 +170,7 @@ function file_get_icon_url( $p_display_filename ) {
*/
function file_path_combine( $p_path, $p_filename ) {
$t_path = $p_path;
if ( substr( $t_path, -1 ) != '/' && substr( $t_path, -1 ) != '\\' ) {
if ( utf8_substr( $t_path, -1 ) != '/' && utf8_substr( $t_path, -1 ) != '\\' ) {
$t_path .= DIRECTORY_SEPARATOR;
}

Expand Down Expand Up @@ -310,7 +310,7 @@ function file_get_visible_attachments( $p_bug_id ) {
$t_attachment['type'] = 'text';
}

if ( $t_can_download && ( $t_filesize != 0 ) && ( $t_filesize <= config_get( 'preview_attachments_inline_max_size' ) ) && ( in_array( strtolower( file_get_extension( $t_attachment['display_name'] ) ), $t_preview_image_ext, true ) ) ) {
if ( $t_can_download && ( $t_filesize != 0 ) && ( $t_filesize <= config_get( 'preview_attachments_inline_max_size' ) ) && ( in_array( utf8_strtolower( file_get_extension( $t_attachment['display_name'] ) ), $t_preview_image_ext, true ) ) ) {
$t_attachment['preview'] = true;
$t_attachment['type'] = 'image';
}
Expand Down Expand Up @@ -840,7 +840,7 @@ function file_ensure_uploaded( $p_file ) {
function file_get_extension( $p_filename ) {
$ext = '';
$dot_found = false;
$i = strlen( $p_filename ) - 1;
$i = utf8_strlen( $p_filename ) - 1;
while( $i >= 0 ) {
if( '.' == $p_filename[$i] ) {
$dot_found = true;
Expand Down
18 changes: 9 additions & 9 deletions core/filter_api.php
Expand Up @@ -406,8 +406,8 @@ function filter_ensure_valid_filter( $p_filter_arr ) {
if( !isset( $p_filter_arr['_version'] ) ) {
$p_filter_arr['_version'] = config_get( 'cookie_version' );
}
$t_cookie_vers = (int) substr( $p_filter_arr['_version'], 1 );
if( substr( config_get( 'cookie_version' ), 1 ) > $t_cookie_vers ) {
$t_cookie_vers = (int) utf8_substr( $p_filter_arr['_version'], 1 );
if( utf8_substr( config_get( 'cookie_version' ), 1 ) > $t_cookie_vers ) {

# if the version is old, update it
$p_filter_arr['_version'] = config_get( 'cookie_version' );
Expand Down Expand Up @@ -536,7 +536,7 @@ function filter_ensure_valid_filter( $p_filter_arr ) {
$t_drop = false;
$t_sort = $t_sort_fields[$i];
if( strpos( $t_sort, 'custom_' ) === 0 ) {
if( false === custom_field_get_id_from_name( substr( $t_sort, strlen( 'custom_' ) ) ) ) {
if( false === custom_field_get_id_from_name( utf8_substr( $t_sort, utf8_strlen( 'custom_' ) ) ) ) {
$t_drop = true;
}
} else {
Expand Down Expand Up @@ -840,7 +840,7 @@ function filter_get_query_sort_data( &$p_filter, $p_show_sticky, $p_query_clause

# if sorting by a custom field
if( strpos( $c_sort, 'custom_' ) === 0 ) {
$t_custom_field = substr( $c_sort, strlen( 'custom_' ) );
$t_custom_field = utf8_substr( $c_sort, utf8_strlen( 'custom_' ) );
$t_custom_field_id = custom_field_get_id_from_name( $t_custom_field );

$c_cf_alias = str_replace( ' ', '_', $t_custom_field );
Expand Down Expand Up @@ -3052,12 +3052,12 @@ function <?php echo $t_js_toggle_func;?>() {
}
$t_sort = $t_sort_fields[$i];
if( strpos( $t_sort, 'custom_' ) === 0 ) {
$t_field_name = string_display( lang_get_defaulted( substr( $t_sort, strlen( 'custom_' ) ) ) );
$t_field_name = string_display( lang_get_defaulted( utf8_substr( $t_sort, utf8_strlen( 'custom_' ) ) ) );
} else {
$t_field_name = string_get_field_name( $t_sort );
}

echo $t_field_name . ' ' . lang_get( 'bugnote_order_' . strtolower( $t_dir_fields[$i] ) );
echo $t_field_name . ' ' . lang_get( 'bugnote_order_' . utf8_strtolower( $t_dir_fields[$i] ) );
echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_', $i, '" value="', $t_sort_fields[$i], '" />';
echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_DIRECTION, '_', $i, '" value="', $t_dir_fields[$i], '" />';
}
Expand Down Expand Up @@ -3738,7 +3738,7 @@ function print_filter_custom_field( $p_field_id ) {
if( is_array( $t_accessible_custom_fields_values[$j] ) ) {
$t_max_length = config_get( 'max_dropdown_length' );
foreach( $t_accessible_custom_fields_values[$j] as $t_item ) {
if(( strtolower( $t_item ) !== META_FILTER_ANY ) && ( strtolower( $t_item ) !== META_FILTER_NONE ) ) {
if(( utf8_strtolower( $t_item ) !== META_FILTER_ANY ) && ( utf8_strtolower( $t_item ) !== META_FILTER_NONE ) ) {
echo '<option value="' . string_html_entities( $t_item ) . '" ';
if( isset( $t_filter['custom_fields'][$p_field_id] ) ) {
check_selected( $t_filter['custom_fields'][$p_field_id], $t_item );
Expand Down Expand Up @@ -3766,7 +3766,7 @@ function print_filter_show_sort() {
for( $i = 0;$i < $t_n_fields;$i++ ) {
if( !in_array( $t_fields[$i], array( 'selection', 'edit', 'bugnotes_count', 'attachment' ) ) ) {
if( strpos( $t_fields[$i], 'custom_' ) === 0 ) {
$t_field_name = string_display( lang_get_defaulted( substr( $t_fields[$i], strlen( 'custom_' ) ) ) );
$t_field_name = string_display( lang_get_defaulted( utf8_substr( $t_fields[$i], utf8_strlen( 'custom_' ) ) ) );
} else {
$t_field_name = string_get_field_name( $t_fields[$i] );
}
Expand Down Expand Up @@ -4376,7 +4376,7 @@ function filter_db_get_available_queries( $p_project_id = null, $p_user_id = nul
* @return bool true when under max_length (64) and false when over
*/
function filter_name_valid_length( $p_name ) {
if( strlen( utf8_decode ( $p_name ) ) > 64 ) {
if( utf8_strlen( utf8_decode ( $p_name ) ) > 64 ) {
return false;
} else {
return true;
Expand Down
2 changes: 1 addition & 1 deletion core/graphviz_api.php
Expand Up @@ -367,7 +367,7 @@ function output( $p_format = 'dot', $p_headers = false ) {
$t_dot_output = $t_graphviz->ToTextGraph( $t_dot_source, $t_type );

if( $p_headers ) {
header( 'Content-Length: ' . strlen( $t_dot_output ) );
header( 'Content-Length: ' . utf8_strlen( $t_dot_output ) );
}

echo $t_dot_output;
Expand Down
2 changes: 1 addition & 1 deletion core/html_api.php
Expand Up @@ -1285,7 +1285,7 @@ function html_button( $p_action, $p_button_text, $p_fields = null, $p_method = '
$p_fields = array();
}

if( strtolower( $p_method ) == 'get' ) {
if( utf8_strtolower( $p_method ) == 'get' ) {
$t_method = 'get';
} else {
$t_method = 'post';
Expand Down
14 changes: 7 additions & 7 deletions core/print_api.php
Expand Up @@ -227,14 +227,14 @@ function print_user_option_list( $p_user_id, $p_project_id = null, $p_access = A
$t_sort_by_last_name = ( ON == config_get( 'sort_by_last_name' ) );
foreach( $t_users as $t_user ) {
$t_user_name = string_attribute( $t_user['username'] );
$t_sort_name = strtolower( $t_user_name );
$t_sort_name = utf8_strtolower( $t_user_name );
if( $t_show_realname && ( $t_user['realname'] <> '' ) ) {
$t_user_name = string_attribute( $t_user['realname'] );
if( $t_sort_by_last_name ) {
$t_sort_name_bits = explode( ' ', strtolower( $t_user_name ), 2 );
$t_sort_name_bits = explode( ' ', utf8_strtolower( $t_user_name ), 2 );
$t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0];
} else {
$t_sort_name = strtolower( $t_user_name );
$t_sort_name = utf8_strtolower( $t_user_name );
}
}
$t_display[] = $t_user_name;
Expand Down Expand Up @@ -313,7 +313,7 @@ function print_tag_option_list( $p_bug_id = 0 ) {
foreach ( $t_rows as $row ) {
$t_string = $row['name'];
if ( !empty( $row['description'] ) ) {
$t_string .= ' - ' . substr( $row['description'], 0, 20 );
$t_string .= ' - ' . utf8_substr( $row['description'], 0, 20 );
}
echo '<option value="', $row['id'], '" title="', $row['name'], '">', $t_string, '</option>';
}
Expand Down Expand Up @@ -1059,10 +1059,10 @@ function print_project_user_list_option_list( $p_project_id = null ) {
if(( isset( $row['realname'] ) ) && ( $row['realname'] <> '' ) && $t_show_realname ) {
$t_user_name = string_attribute( $row['realname'] );
if( $t_sort_by_last_name ) {
$t_sort_name_bits = explode( ' ', strtolower( $t_user_name ), 2 );
$t_sort_name_bits = explode( ' ', utf8_strtolower( $t_user_name ), 2 );
$t_sort_name = ( isset( $t_sort_name_bits[1] ) ? $t_sort_name_bits[1] . ', ' : '' ) . $t_sort_name_bits[0];
} else {
$t_sort_name = strtolower( $t_user_name );
$t_sort_name = utf8_strtolower( $t_user_name );
}
}
$t_display[] = $t_user_name;
Expand Down Expand Up @@ -1569,7 +1569,7 @@ function print_sql_error( $p_query ) {
function print_file_icon( $p_filename ) {
$t_file_type_icons = config_get( 'file_type_icons' );

$ext = strtolower( file_get_extension( $p_filename ) );
$ext = utf8_strtolower( file_get_extension( $p_filename ) );
if( !isset( $t_file_type_icons[$ext] ) ) {
$ext = '?';
}
Expand Down
10 changes: 5 additions & 5 deletions core/relationship_api.php
Expand Up @@ -590,7 +590,7 @@ function relationship_can_resolve_bug( $p_bug_id ) {
* @return string
*/
function relationship_get_details( $p_bug_id, $p_relationship, $p_html = false, $p_html_preview = false, $p_show_project = false ) {
$t_summary_wrap_at = strlen( config_get( 'email_separator2' ) ) - 28;
$t_summary_wrap_at = utf8_strlen( config_get( 'email_separator2' ) ) - 28;
$t_icon_path = config_get( 'icon_path' );

if( $p_bug_id == $p_relationship->src_bug_id ) {
Expand Down Expand Up @@ -637,8 +637,8 @@ function relationship_get_details( $p_bug_id, $p_relationship, $p_html = false,
$t_relationship_info_html .= $t_td . $t_status . '&nbsp;</td>';
}

$t_relationship_info_text = str_pad( $t_relationship_descr, 20 );
$t_relationship_info_text .= str_pad( bug_format_id( $t_related_bug_id ), 8 );
$t_relationship_info_text = utf8_str_pad( $t_relationship_descr, 20 );
$t_relationship_info_text .= utf8_str_pad( bug_format_id( $t_related_bug_id ), 8 );

# get the handler name of the related bug
$t_relationship_info_html .= $t_td;
Expand All @@ -659,10 +659,10 @@ function relationship_get_details( $p_bug_id, $p_relationship, $p_html = false,
$t_relationship_info_html .= sprintf( ' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get( 'private' ), lang_get( 'private' ) );
}
} else {
if( strlen( $t_bug->summary ) <= $t_summary_wrap_at ) {
if( utf8_strlen( $t_bug->summary ) <= $t_summary_wrap_at ) {
$t_relationship_info_text .= string_email_links( $t_bug->summary );
} else {
$t_relationship_info_text .= mb_substr( string_email_links( $t_bug->summary ), 0, $t_summary_wrap_at - 3 ) . '...';
$t_relationship_info_text .= utf8_substr( string_email_links( $t_bug->summary ), 0, $t_summary_wrap_at - 3 ) . '...';
}
}

Expand Down
29 changes: 5 additions & 24 deletions core/string_api.php
Expand Up @@ -35,25 +35,6 @@
$g_cache_html_valid_tags = '';
$g_cache_html_valid_tags_single_line = '';

if ( function_exists( 'mb_strtolower' ) ) {
/**
* Return a string with all alphabetical characters converted to lowercase,
* using an appropriate multibyte implementation as available to system.
* @param string Input string
* @return string Lower cased string
*/
function string_lower( $p_string ) {
return mb_strtolower( $p_string );
}
} else {
/**
* @ignore
*/
function string_lower( $p_string ) {
return strtolower( $p_string );
}
}

/**
* Preserve spaces at beginning of lines.
* Lines must be separated by \n rather than <br />
Expand All @@ -67,7 +48,7 @@ function string_preserve_spaces_at_bol( $p_string ) {
$count = 0;
$prefix = '';

$t_char = substr( $lines[$i], $count, 1 );
$t_char = utf8_substr( $lines[$i], $count, 1 );
$spaces = 0;
while(( $t_char == ' ' ) || ( $t_char == "\t" ) ) {
if( $t_char == ' ' ) {
Expand All @@ -79,14 +60,14 @@ function string_preserve_spaces_at_bol( $p_string ) {
// 1 tab = 4 spaces, can be configurable.

$count++;
$t_char = substr( $lines[$i], $count, 1 );
$t_char = utf8_substr( $lines[$i], $count, 1 );
}

for( $j = 0;$j < $spaces;$j++ ) {
$prefix .= '&nbsp;';
}

$lines[$i] = $prefix . substr( $lines[$i], $count );
$lines[$i] = $prefix . utf8_substr( $lines[$i], $count );
}
return implode( "\n", $lines );
}
Expand Down Expand Up @@ -810,7 +791,7 @@ function string_shorten( $p_string, $p_max = null ) {
$t_max = (int) $p_max;
}

if( ( $t_max > 0 ) && ( strlen( $p_string ) > $t_max ) ) {
if( ( $t_max > 0 ) && ( utf8_strlen( $p_string ) > $t_max ) ) {
$t_pattern = '/([\s|.|,|\-|_|\/|\?]+)/';
$t_bits = preg_split( $t_pattern, $p_string, -1, PREG_SPLIT_DELIM_CAPTURE );

Expand All @@ -819,7 +800,7 @@ function string_shorten( $p_string, $p_max = null ) {
$t_last_len = strlen( $t_last );

foreach( $t_bits as $t_bit ) {
if(( strlen( $t_string ) + strlen( $t_bit ) + $t_last_len + 3 <= $t_max ) || ( strpos( $t_bit, '.,-/?' ) > 0 ) ) {
if(( utf8_strlen( $t_string ) + utf8_strlen( $t_bit ) + $t_last_len + 3 <= $t_max ) || ( strpos( $t_bit, '.,-/?' ) > 0 ) ) {
$t_string .= $t_bit;
} else {
break;
Expand Down
2 changes: 1 addition & 1 deletion core/utility_api.php
Expand Up @@ -64,7 +64,7 @@ function terminate_directory_path( $p_path ) {
*/
function is_blank( $p_var ) {
$p_var = trim( $p_var );
$str_len = strlen( $p_var );
$str_len = utf8_strlen( $p_var );
if( 0 == $str_len ) {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions manage_proj_edit_page.php
Expand Up @@ -743,14 +743,14 @@
$t_sort = array();
foreach ( $t_users as $t_user ) {
$t_user_name = string_attribute( $t_user['username'] );
$t_sort_name = strtolower( $t_user_name );
$t_sort_name = utf8_strtolower( $t_user_name );
if ( ( isset( $t_user['realname'] ) ) && ( $t_user['realname'] > "" ) && ( ON == config_get( 'show_realname' ) ) ){
$t_user_name = string_attribute( $t_user['realname'] ) . " (" . $t_user_name . ")";
if ( ON == config_get( 'sort_by_last_name') ) {
$t_sort_name_bits = explode( ' ', strtolower( $t_user_name ), 2 );
$t_sort_name_bits = explode( ' ', utf8_strtolower( $t_user_name ), 2 );
$t_sort_name = $t_sort_name_bits[1] . ', ' . $t_sort_name_bits[1];
} else {
$t_sort_name = strtolower( $t_user_name );
$t_sort_name = utf8_strtolower( $t_user_name );
}
}
$t_display[] = $t_user_name;
Expand Down

0 comments on commit a5bf55d

Please sign in to comment.