Skip to content

Commit

Permalink
Following siebrands commit to remove non-utf8 language files, we can …
Browse files Browse the repository at this point in the history
…remove calls to lang_get(charset) as we also return utf8 now
  • Loading branch information
mantis committed May 2, 2009
1 parent a927893 commit a3cee1b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 29 deletions.
4 changes: 1 addition & 3 deletions admin/install.php
Expand Up @@ -695,9 +695,7 @@ function InsertData( $p_table, $p_data ) {

# Make sure we do the upgrades using UTF-8 if needed
if ( $f_db_type === 'mysql' || $f_db_type === 'mysqli' ) {
if( strtolower( lang_get( 'charset' ) ) === 'utf-8' ) {
$g_db->execute( 'SET NAMES UTF8' );
}
$g_db->execute( 'SET NAMES UTF8' );
}

if( $f_db_type == 'db2' ) {
Expand Down
2 changes: 1 addition & 1 deletion core.php
Expand Up @@ -245,5 +245,5 @@ function __autoload( $className ) {
lang_push( lang_get_default() );

if ( !isset( $g_bypass_headers ) && !headers_sent() ) {
header( 'Content-type: text/html;charset=' . lang_get( 'charset' ) );
header( 'Content-type: text/html;charset=utf-8' );
}
10 changes: 5 additions & 5 deletions core/error_api.php
Expand Up @@ -226,7 +226,7 @@ function error_print_details( $p_file, $p_line, $p_context ) {
<center>
<table class="width75">
<tr>
<td>Full path: <?php echo htmlentities( $p_file, ENT_COMPAT, lang_get( 'charset' ) );?></td>
<td>Full path: <?php echo htmlentities( $p_file, ENT_COMPAT, 'UTF-8' );?></td>
</tr>
<tr>
<td>Line: <?php echo $p_line?></td>
Expand Down Expand Up @@ -257,7 +257,7 @@ function error_print_context( $p_context ) {
foreach( $p_context as $t_var => $t_val ) {
if( !is_array( $t_val ) && !is_object( $t_val ) ) {
$t_type = gettype( $t_val );
$t_val = htmlentities( (string) $t_val, ENT_COMPAT, lang_get( 'charset' ) );
$t_val = htmlentities( (string) $t_val, ENT_COMPAT, 'UTF-8' );

# Mask Passwords
if( strpos( $t_var, 'password' ) !== false ) {
Expand Down Expand Up @@ -300,14 +300,14 @@ function error_print_stack_trace() {

foreach( $t_stack as $t_frame ) {
echo '<tr ', error_alternate_class(), '>';
echo '<td>', ( isset( $t_frame['file'] ) ? htmlentities( $t_frame['file'], ENT_COMPAT, lang_get( 'charset' ) ) : '-' ), '</td><td>', ( isset( $t_frame['line'] ) ? $t_frame['line'] : '-' ), '</td><td>', ( isset( $t_frame['class'] ) ? $t_frame['class'] : '-' ), '</td><td>', ( isset( $t_frame['type'] ) ? $t_frame['type'] : '-' ), '</td><td>', ( isset( $t_frame['function'] ) ? $t_frame['function'] : '-' ), '</td>';
echo '<td>', ( isset( $t_frame['file'] ) ? htmlentities( $t_frame['file'], ENT_COMPAT, 'UTF-8' ) : '-' ), '</td><td>', ( isset( $t_frame['line'] ) ? $t_frame['line'] : '-' ), '</td><td>', ( isset( $t_frame['class'] ) ? $t_frame['class'] : '-' ), '</td><td>', ( isset( $t_frame['type'] ) ? $t_frame['type'] : '-' ), '</td><td>', ( isset( $t_frame['function'] ) ? $t_frame['function'] : '-' ), '</td>';

$t_args = array();
if( isset( $t_frame['args'] ) && !empty( $t_frame['args'] ) ) {
foreach( $t_frame['args'] as $t_value ) {
$t_args[] = error_build_parameter_string( $t_value );
}
echo '<td>( ', htmlentities( implode( $t_args, ', ' ), ENT_COMPAT, lang_get( 'charset' ) ), ' )</td></tr>';
echo '<td>( ', htmlentities( implode( $t_args, ', ' ), ENT_COMPAT, 'UTF-8' ), ' )</td></tr>';
} else {
echo '<td>-</td></tr>';
}
Expand Down Expand Up @@ -375,7 +375,7 @@ function error_string( $p_error ) {

# ripped from string_api
$t_string = call_user_func_array( 'sprintf', array_merge( array( $t_error ), $g_error_parameters, $t_padding ) );
return preg_replace( "/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", @htmlspecialchars( $t_string, ENT_COMPAT, lang_get( 'charset' ) ) );
return preg_replace( "/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", @htmlspecialchars( $t_string, ENT_COMPAT, 'UTF-8' ) );
}

/**
Expand Down
5 changes: 2 additions & 3 deletions core/html_api.php
Expand Up @@ -273,7 +273,7 @@ function html_head_begin() {
* @return null
*/
function html_content_type() {
echo "\t", '<meta http-equiv="Content-type" content="text/html;charset=', lang_get( 'charset' ), '" />', "\n";
echo "\t", '<meta http-equiv="Content-type" content="text/html;charset=utf-8" />', "\n";
}

/**
Expand Down Expand Up @@ -593,7 +593,6 @@ function html_footer( $p_file ) {
if( ON == config_get( 'show_queries_list' ) ) {
echo "\t", '<table>', "\n";
$t_total = 0;
$t_lang_charset = lang_get( 'charset' );
for( $i = 0;$i < $t_count;$i++ ) {
$t_time = $g_queries_array[$i][1];
$t_caller = $g_queries_array[$i][2];
Expand All @@ -604,7 +603,7 @@ function html_footer( $p_file ) {
}
echo "\t", '<tr valign="top"><td', $t_style_tag, '>', ( $i + 1 ), '</td>';
echo '<td', $t_style_tag, '>', $t_time, '</td>';
echo '<td', $t_style_tag, '><span style="color: gray;">', $t_caller, '</span><br />', string_html_specialchars( $g_queries_array[$i][0], $t_lang_charset ), '</td></tr>', "\n";
echo '<td', $t_style_tag, '><span style="color: gray;">', $t_caller, '</span><br />', string_html_specialchars( $g_queries_array[$i][0] ), '</td></tr>', "\n";
}

# @@@ Note sure if we should localize them given that they are debug info. Will add if requested by users.
Expand Down
5 changes: 2 additions & 3 deletions core/print_api.php
Expand Up @@ -91,7 +91,7 @@ function print_header_redirect( $p_url, $p_die = true, $p_sanitize = false, $p_a

# don't send more headers if they have already been sent (guideweb)
if( !headers_sent() ) {
header( 'Content-Type: text/html; charset=' . lang_get( 'charset' ) );
header( 'Content-Type: text/html; charset=utf-8' );

if( ON == $t_use_iis ) {
header( "Refresh: 0;url=$t_url" );
Expand Down Expand Up @@ -467,13 +467,12 @@ function print_project_option_list( $p_project_id = null, $p_include_all_project
}

$t_project_count = count( $t_project_ids );
$t_charset = lang_get( 'charset' );
for( $i = 0;$i < $t_project_count;$i++ ) {
$t_id = $t_project_ids[$i];
if( $t_id != $p_filter_project_id ) {
echo "<option value=\"$t_id\"";
check_selected( $p_project_id, $t_id );
echo '>' . string_html_specialchars( string_strip_hrefs( project_get_field( $t_id, 'name' ) ), $t_charset ) . '</option>' . "\n";
echo '>' . string_html_specialchars( string_strip_hrefs( project_get_field( $t_id, 'name' ) ) ) . '</option>' . "\n";
print_subproject_option_list( $t_id, $p_project_id, $p_filter_project_id, $p_trace, Array(), $t_charset );
}
}
Expand Down
15 changes: 4 additions & 11 deletions core/string_api.php
Expand Up @@ -748,25 +748,18 @@ function string_get_field_name( $p_string ) {
# --------------------
# Calls htmlentities on the specified string, passing along
# the current charset.
function string_html_entities( $p_string, $p_charset = null ) {
if ( $p_charset === null ) {
$p_charset = lang_get( 'charset' );
}
return htmlentities( $p_string, ENT_COMPAT, $p_charset );
function string_html_entities( $p_string ) {
return htmlentities( $p_string, ENT_COMPAT, 'utf-8' );
}

# --------------------
# Calls htmlspecialchars on the specified string, passing along
# the current charset, if the current PHP version supports it.
function string_html_specialchars( $p_string, $p_charset = null ) {
if ( $p_charset === null ) {
$p_charset = lang_get( 'charset' );
}

function string_html_specialchars( $p_string ) {
# achumakov: @ added to avoid warning output in unsupported codepages
# e.g. 8859-2, windows-1257, Korean, which are treated as 8859-1.
# This is VERY important for Eastern European, Baltic and Korean languages
return preg_replace( "/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", @htmlspecialchars( $p_string, ENT_COMPAT, $p_charset ) );
return preg_replace( "/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", @htmlspecialchars( $p_string, ENT_COMPAT, 'utf-8' ) );
}

# --------------------
Expand Down
2 changes: 1 addition & 1 deletion issues_rss.php
Expand Up @@ -78,7 +78,7 @@

# construct rss file

$encoding = lang_get( 'charset' );
$encoding = 'utf-8';
$about = $t_path;
$title = string_rss_links( config_get( 'window_title' ) );
$image_link = $t_path . 'images/mantis_logo_button.gif';
Expand Down
2 changes: 1 addition & 1 deletion news_rss.php
Expand Up @@ -60,7 +60,7 @@

# construct rss file

$encoding = lang_get( 'charset' );
$encoding = 'utf-8';
$about = config_get( 'path' );
$title = string_rss_links( config_get( 'window_title' ) . ' - ' . lang_get( 'news' ) );

Expand Down
2 changes: 1 addition & 1 deletion return_dynamic_filters.php
Expand Up @@ -105,7 +105,7 @@
function act(){
if(isset($_GET['filter_target'])){
if ( !headers_sent() ) {
header( 'Content-Type: text/html; charset=' . lang_get( 'charset' ) );
header( 'Content-Type: text/html; charset=utf-8' );
}
$filter = $_GET['filter_target'];
$t_functionName = 'print_filter_'. substr($filter,0,-7);
Expand Down

0 comments on commit a3cee1b

Please sign in to comment.