View Issue Details

IDProjectCategoryView StatusLast Update
0012076mantisbtattachmentspublic2010-06-16 10:04
Reporterdominik Assigned To 
Status newResolutionopen 
Product Version1.2.1 
Summary0012076: Problems with Handling of File names containing "-" (attachments)

The function file_get_display_name() contains code to manipulate the filename (i guess in earlier versions a fix scheme like 0000000-filename was used) so if you have a file name lik 1234567-test.pdf the function will return test.pdf instead of 1234567-test.pdf

I don't know since when this naming scheme is no longer in use but wouldn't it make sense to make sure (eg. in the upgrade script) that all filenames will use the "new" (no) scheme and not any longer the "old" one and to remove that code snippet? Or am I missing something?

As a workaround I added a config switch for my installation to disable this behaviour.

Additional Information


  • Old versions of Mantis use special schema for filenaming (eg. 0000000-filename)
  • This may lead to problems when using similar file names
  • @global bool $g_special_handling_for_old_filenames
    $g_special_handling_for_old_filenames = OFF;

function file_get_display_name( $p_filename ) {
$t_array = explode( '-', $p_filename, 2 );

Check if it's a project document filename (doc-0000000-filename)

or a bug attachment filename (0000000-filename)

for newer filenames, the filename in schema is correct.

This is important to handle filenames with '-'s properly

$t_doc_match = '/^' . config_get( 'document_files_prefix' ) . '-\d{7}-/';
$t_name = preg_split( $t_doc_match, $p_filename );
if( isset( $t_name[1] ) ) {
return $t_name[1];
} else {
if ( config_get( 'special_handling_for_old_filenames' ) ) {
$t_bug_match = '/^\d{7}-/';
$t_name = preg_split( $t_bug_match, $p_filename );
if( isset( $t_name[1] ) ) {
return $t_name[1];
return $p_filename;

TagsNo tags attached.


There are no notes attached to this issue.