Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Periods (.) stripped from file name?  (Read 3136 times)

0 Members and 1 Guest are viewing this topic.

samsonpablo

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Periods (.) stripped from file name?
« 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?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Periods (.) stripped from file name?
« Reply #1 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;
Logged

samsonpablo

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Periods (.) stripped from file name?
« Reply #2 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15760
Re: Periods (.) stripped from file name?
« Reply #3 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 19 queries.