Skip to content

Commit

Permalink
Fix: 0010421: Default filename corrupted if project name contains spe…
Browse files Browse the repository at this point in the history
…cial chars
  • Loading branch information
mantis committed May 26, 2009
1 parent e45b8f8 commit d2f77f2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/excel_api.php
Expand Up @@ -30,6 +30,7 @@
* @returns the header Xml.
*/
function excel_get_header( $p_worksheet_title ) {
$p_worksheet_title = preg_replace( '/[\/:*?"<>|]/', '', $p_worksheet_title );
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?mso-application progid=\"Excel.Sheet\"?>
<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"
xmlns:x=\"urn:schemas-microsoft-com:office:excel\"
Expand Down
2 changes: 1 addition & 1 deletion core/file_api.php
Expand Up @@ -557,7 +557,7 @@ function file_type_check( $p_file_name ) {

# clean file name by removing sensitive characters and replacing them with underscores
function file_clean_name( $p_filename ) {
return preg_replace( "/[\/\\ :&]/", "_", $p_filename );
return preg_replace( '/[\/*?"<>|\\ :&]/', "_", $p_filename );
}

# Generate a string to use as the identifier for the file
Expand Down
4 changes: 2 additions & 2 deletions csv_export.php
Expand Up @@ -56,11 +56,11 @@
# Make sure that IE can download the attachments under https.
header( 'Pragma: public' );

header( 'Content-Type: text/plain; name=' . urlencode( $t_filename ) );
header( 'Content-Type: text/plain; name=' . urlencode( file_clean_name( $t_filename ) ) );
header( 'Content-Transfer-Encoding: BASE64;' );

# Added Quotes (") around file name.
header( 'Content-Disposition: attachment; filename="' . urlencode( $t_filename ) . '"' );
header( 'Content-Disposition: attachment; filename="' . urlencode( file_clean_name( $t_filename ) ) . '"' );

# Get columns to be exported
$t_columns = csv_get_columns();
Expand Down
3 changes: 1 addition & 2 deletions excel_xml_export.php
Expand Up @@ -44,7 +44,6 @@
helper_begin_long_process();

$t_export_title = excel_get_default_filename();
$t_export_title = preg_replace( '/[\/:*?"<>|]/', '', $t_export_title );

$t_short_date_format = config_get( 'short_date_format' );

Expand All @@ -62,7 +61,7 @@
header( 'Content-Type: application/vnd.ms-excel; charset=UTF-8' );
header( 'Pragma: public' );
header( 'Content-Type: application/vnd.ms-excel' );
header( 'Content-Disposition: attachment; filename="' . urlencode( $t_export_title ) . '.xml"' ) ;
header( 'Content-Disposition: attachment; filename="' . urlencode( file_clean_name( $t_export_title ) ) . '.xml"' ) ;

echo excel_get_header( $t_export_title );
echo excel_get_titles_row();
Expand Down

0 comments on commit d2f77f2

Please sign in to comment.