forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 upload => Topic started by: samsonpablo on February 22, 2012, 08:53:49 pm

Title: Periods (.) stripped from file name?
Post by: samsonpablo on February 22, 2012, 08:53:49 pm
I've noticed that multiple periods occurring before the file extension are converted to underscores even though they are not present in forbiden_fname_char. Most of the images we have are of the format AA.BB.CCCCC.png where AA.BB.CCCCC is a unique identifier. It would be handy to be able to search for AA.BB.CCCCC in the search function, searching filenames but this does not seen to work since AA.BB.CCCCC.png is converted to AA_BB_CCCCC.png.

Any pointers on modifying this behavior?
Title: Re: Periods (.) stripped from file name?
Post by: Αndré on February 24, 2012, 02:08:59 pm
Have a look at the function replace_forbidden in include/functions.inc.php. I haven't tested that, but I think it should work when you delete/comment out the following code block:
Code: [Select]
    /**
     * Fix the obscure, misdocumented "feature" in Apache that causes the server
     * to process the last "valid" extension in the filename (rar exploit): replace all
     * dots in the filename except the last one with an underscore.
     */
    // This could be concatenated into a more efficient string later, keeping it in three
    // lines for better readability for now.
    $extension = ltrim(substr($return, strrpos($return, '.')), '.');

    $filenameWithoutExtension = str_replace('.' . $extension, '', $return);

    $return = str_replace('.', '_', $filenameWithoutExtension) . '.' . $extension;
Title: Re: Periods (.) stripped from file name?
Post by: samsonpablo on February 28, 2012, 07:07:21 pm
Ah, beautiful. Works good for what I'm doing. I didn't get down to that part of the function, I was obsessing over the first 20 lines  :-[ Thank you.
Title: Re: Periods (.) stripped from file name?
Post by: Αndré on March 01, 2012, 01:46:07 pm
Please
tag your answer as "solved" by clicking on the "Topic Solved" button on the bar at the left hand side at the bottom of your thread.