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] 2   Go Down

Author Topic: Spaces in filenames issue  (Read 12564 times)

0 Members and 1 Guest are viewing this topic.

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Spaces in filenames issue
« on: September 18, 2005, 09:32:13 pm »

I suppose the seasoned copperminer is probably aware of issues surrounding the use of blank spaces in uploaded filenames. I'm not so sure that a neophyte would, though.

Anyone can FTP files with spaces in them into folders, like  "my dad.jpg" .
Batch adding these files work in 1.4x. It creates "normal_my dad.jpg" and "thumb_my dad.jpg" But, notice that there is no _underscore_  between the words "my" and "dad".

Therefore a problem arrises when one tries to rename these files.
If you try to rename "my dad.jpg" to "dad.jpg"
You get a "Critical Error  file my%20dad.jpg is missing."

If you then make a copy of "my dad.jpg" in the upload folder and rename it my%20dad.jpg and repeat the renaming procedure. You get a "Critical Error file my%20dad.jpg already exists."

The only solution then is to delete the file and upload it again.

------

On a  related issue.   If a user inadvertantly edits a file name like "hometown.jpg" to "my hometown.jpg"  The change appears to work without a hitch. Trying to rename the resulting filename, however, produces the same problems above.

------
Shouldn't filenames with spaces trigger a warning or error message during the batch upload and file renaming process?  Or is there a fix? 

Dennis

Related topics: http://forum.coppermine-gallery.net/index.php?topic=9787.0
                 http://forum.coppermine-gallery.net/index.php?topic=14026.msg64901#msg64901

« Last Edit: September 22, 2005, 03:36:16 pm by GauGau »
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Spaces in filenames issue
« Reply #1 on: September 19, 2005, 08:45:47 am »

Nibbler, could you please take a look into this issue (the file renaming feature in util.php)?
Logged

Aditya Mooley

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 781
    • My Sweet Home
Re: Spaces in filenames issue
« Reply #2 on: September 19, 2005, 11:59:10 am »

Quote
Anyone can FTP files with spaces in them into folders, like  "my dad.jpg" .
Batch adding these files work in 1.4x. It creates "normal_my dad.jpg" and "thumb_my dad.jpg" But, notice that there is no _underscore_  between the words "my" and "dad".

This won't be the problem anymore, since we are replacing all the forbidden characters with underscore as we do in normal upload process.
Ofcourse, we still need to modify util.php as GauGau has suggested.
Logged
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #3 on: September 21, 2005, 06:32:21 am »

Aditya,

Quote
This won't be the problem anymore, since we are replacing all the forbidden characters with underscore as we do in normal upload process.

I downloaded the two updated files from CVS but the 'fix' to rename files with spaces, didn't work. FTP'd files with spaces still were left with spaces in their names and normal and thumb files still contain spaces in their names.   i.e. "my dog.jpg" would be "thumb_my dog.jpg".  Cleared my cookies and all temp files and tried again, still no go.  All the issues I commented on in this thread still exist.


Dennis
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Aditya Mooley

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 781
    • My Sweet Home
Re: Spaces in filenames issue
« Reply #4 on: September 21, 2005, 07:02:37 am »

I hope you also downloaded update.sql and run update.php before trying this.
We have added space and "&" in the list of default forbidden characters.
Logged
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #5 on: September 21, 2005, 07:06:56 am »

I hope you also downloaded update.sql and run update.php before trying this.
We have added space and "&" in the list of default forbidden characters.

AHA!  okay will do and will test it out again shortly. Thanks.   

Dennis
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Spaces in filenames issue
« Reply #6 on: September 21, 2005, 07:17:53 am »

Dennis,

it's recommended to check out all files when addressing bug fixes, take a look at http://forum.coppermine-gallery.net/index.php?topic=7947.msg77748#msg77748 - there's an explanation how to use cvs software with coppermine.
Logged

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #7 on: September 21, 2005, 07:55:40 am »

Thanks gaugau,

I've been going through each of the CVS folders one by one, downloading latest updates that way. :-)   Somehow, I missed the update.sql.

Dennis
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #8 on: September 21, 2005, 09:36:16 am »

Aditya,

Sorry, maybe I'm still doing something wrong.  I updated all three files, cleared my cache, cleared my cookies, rebooted. Then I proceeded to do the following.

1)  I copied and pasted a file named pan_001.jpg into the same upload directory and ended up with a file named "copy of pan_001.jpg"

2)  I renamed the file "copy of&pan_001.jpg"  to test both the space and ampersand(&) forbidden character set fix.

3) I ran the batch add script and while the updates did correct the file name to "copy of_pan_001.jpg"   You will note that it did not place an underscore between "copy" and "of".


It's still not catching blank spaces.

Dennis

Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Nibbler

  • Guest
Re: Spaces in filenames issue
« Reply #9 on: September 21, 2005, 09:54:10 am »

Did you run update.php ?
Logged

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #10 on: September 21, 2005, 10:03:31 am »

Did you run update.php ?

Yes, but I found the error!

In the update.sql file, line 240 should read:

UPDATE `CPG_config` SET value='$/\\\\:*?"\'<>|` & ;' WHERE name='forbiden_fname_char';

NOTE the extra semicolon at the end separated by a space from the previous one.  Doing this corrected all the above bugs.  Even when I try to rename a file in the edit screen, it will underscore spaces for me now.


Dennis
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Aditya Mooley

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 781
    • My Sweet Home
Re: Spaces in filenames issue
« Reply #11 on: September 21, 2005, 11:02:02 am »

Hey Dennis, congrats, finally it worked for you :)
But the update query seems to be fine in devel. I just updated my devel and there is no extra ";"

@devs - Can someone please confirm this?
Logged
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #12 on: September 21, 2005, 11:08:43 am »

Hey Dennis, congrats, finally it worked for you :)
But the update query seems to be fine in devel. I just updated my devel and there is no extra ";"

@devs - Can someone please confirm this?

Sorry Aditya, obviously I wasn't very clear in that last post.  What I meant to say is that I had to ADD that extra space and semi-colon to make the update work.  And in adding that space and semi-colon to the update, it also resolved the renaming issue as well.

So instead of this which is in the devel CVS update.sql
Quote
UPDATE `CPG_config` SET value='$/\\\\:*?"\'<>|` &' WHERE name='forbiden_fname_char';

I think it should be:
Quote
UPDATE `CPG_config` SET value='$/\\\\:*?"\'<>|` & ;' WHERE name='forbiden_fname_char';

Can others confirm this, please?

Dennis
« Last Edit: September 21, 2005, 11:54:00 am by madeinhawaii »
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Aditya Mooley

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 781
    • My Sweet Home
Re: Spaces in filenames issue
« Reply #13 on: September 21, 2005, 12:18:51 pm »

Dennis,
I have my local setup running fine with first query. I even tried to change the filename using edit pic and it coverted spaces to underscore.

I think we should wait for other dev's comments on this.

Just to make sure, is the line 2891 in functions.inc.php is exactly like
Code: [Select]
$chars = strtr($CONFIG['forbiden_fname_char'], array('&amp;' => '&', '&quot;' => '"', '&lt;' => '<', '&gt;' => '>', '&nbsp;' => ' '));
?
Logged
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #14 on: September 21, 2005, 12:23:44 pm »


Just to make sure, is the line 2891 in functions.inc.php is exactly like
Code: [Select]
$chars = strtr($CONFIG['forbiden_fname_char'], array('&amp;' => '&', '&quot;' => '"', '&lt;' => '<', '&gt;' => '>', '&nbsp;' => ' '));
?

Yes, mine is identical.

Dennis
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.

Aditya Mooley

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 781
    • My Sweet Home
Re: Spaces in filenames issue
« Reply #15 on: September 21, 2005, 12:28:42 pm »

Now its time to hear something from someone else.
Logged
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

Nibbler

  • Guest
Re: Spaces in filenames issue
« Reply #16 on: September 21, 2005, 12:39:27 pm »

I confirm madeinhawaii's findings, the version in devel does not appear to do anything.
Logged

Aditya Mooley

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 781
    • My Sweet Home
Re: Spaces in filenames issue
« Reply #17 on: September 21, 2005, 01:37:43 pm »

Hmmm
Bug in our code :(
&nbsp; was not getting replaced with space which caused all the confusion. It may have something to do with ASCII value of space.
Anyways, we have fixed it and seems like it is working now.

Thanks Dennis for testing. I would appreciate if you can once again test it.

Thanks,
Aditya
Logged
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

Nibbler

  • Guest
Re: Spaces in filenames issue
« Reply #18 on: September 21, 2005, 03:34:07 pm »

[Commited fix for renaming existing files with spaces into editOnePic.php]
Logged

artistsinhawaii

  • VIP
  • Coppermine addict
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 856
    • evj art and photography
Re: Spaces in filenames issue
« Reply #19 on: September 21, 2005, 09:09:16 pm »

I would appreciate if you can once again test it.

I removed the previous entry from my database, installed the new update.sql and ran update.
I confirmed that the update changed the entry, then repeated all the previous steps and it worked until I tested the ampersand (&) issue.

While there is no longer any issue with spaces or ampersands when I batch add.

We now have an issue with renaming again.
When I try to rename a file eg:   
                 Copy_of_pan_001.jpg  --->  1 2&Copy_of_pan_001.jpg   
I get          1_2_amp;Copy_of_Pan_001.jpg



AS a further test, I took the file
                                           copy_of_pan_001.jpg
Tried Edit filename to:            1 2@3"4?5\6&7>8<copy_of_Pan_001.jpg       
Result:                                 1_2@3_quot;4_5_6_amp;7_gt;8_lt;Copy_of_Pan_001.jpg

and of course, the resulting file can no longer be renamed.

Sorry Aditya, hope this won't be too difficult to correct.


Dennis
« Last Edit: September 21, 2005, 11:00:04 pm by madeinhawaii »
Logged
Learn and live ... In January of 2011, after a botched stent attempt, the doctors told me I needed a multiple bypass surgery or I could die.  I told them I needed new doctors.
Pages: [1] 2   Go Up
 

Page created in 0.037 seconds with 20 queries.