Skip to content

Commit

Permalink
Fix duplicate BOM and use constant for BOM
Browse files Browse the repository at this point in the history
  • Loading branch information
vboctor committed Mar 7, 2016
1 parent 120d451 commit 851786e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
4 changes: 3 additions & 1 deletion billing_export_to_csv.php
Expand Up @@ -53,7 +53,9 @@
$t_show_realname = config_get( 'show_realname' ) == ON;

csv_emit_headers( $t_filename );
echo csv_get_byteordermarker();
if( config_get( 'csv_add_bom' ) == ON ) {
echo UTF8_BOM;
}

echo csv_escape_string( lang_get( 'issue_id' ) ) . $t_separator;
echo csv_escape_string( lang_get( 'project_name' ) ) . $t_separator;
Expand Down
3 changes: 3 additions & 0 deletions core/constant_inc.php
Expand Up @@ -602,3 +602,6 @@
define ( 'JQUERY_VERSION', '1.11.3' );
define ( 'JQUERY_UI_VERSION', '1.11.4' );

# Byte Order Markers
define( 'UTF8_BOM', "\xEF\xBB\xBF" );

8 changes: 0 additions & 8 deletions core/csv_api.php
Expand Up @@ -58,14 +58,6 @@ function csv_emit_headers( $p_filename ) {
header( 'Content-Disposition: attachment; filename="' . urlencode( file_clean_name( $p_filename ) ) . '"' );
}

/**
* Generates the byte order marker (BOM) to be generated at the top of the csv file.
* @return string The byte order marker.
*/
function csv_get_byteordermarker() {
return "\xEF\xBB\xBF";
}

/**
* get the csv file new line, can be moved to config in the future
* @return string containing new line character
Expand Down
9 changes: 3 additions & 6 deletions csv_export.php
Expand Up @@ -69,16 +69,13 @@
$t_filename = csv_get_default_filename();

csv_emit_headers( $t_filename );
echo csv_get_byteordermarker();
if( config_get( 'csv_add_bom' ) == ON ) {
echo UTF8_BOM;
}

# Get columns to be exported
$t_columns = csv_get_columns();

# export BOM
if( config_get( 'csv_add_bom' ) == ON ) {
echo "\xEF\xBB\xBF";
}

# export the titles
$t_first_column = true;
ob_start();
Expand Down

0 comments on commit 851786e

Please sign in to comment.