Periods (.) stripped from file name? Periods (.) stripped from file name?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Periods (.) stripped from file name?

Started by samsonpablo, February 22, 2012, 08:53:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

samsonpablo

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?

Αndré

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:
    /**
     * 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;

samsonpablo

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.

Αndré

Please
Quote from: Joachim Müller on September 28, 2008, 12:46:26 PM
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.