Spaces in filenames issue Spaces in filenames issue
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Spaces in filenames issue

Started by artistsinhawaii, September 18, 2005, 09:32:13 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

artistsinhawaii

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

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

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

Aditya Mooley

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.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

Aditya,

QuoteThis 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
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

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.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

Quote from: Aditya Mooley 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.

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

Dennis
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

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.

artistsinhawaii

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
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

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

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


artistsinhawaii

Quote from: Nibbler on September 21, 2005, 09:54:10 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
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

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?
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

#12
Quote from: Aditya Mooley 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?

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
QuoteUPDATE `CPG_config` SET value='$/\\\\:*?"\'<>|` &' WHERE name='forbiden_fname_char';

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

Can others confirm this, please?

Dennis
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

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

$chars = strtr($CONFIG['forbiden_fname_char'], array('&amp;' => '&', '&quot;' => '"', '&lt;' => '<', '&gt;' => '>', '&nbsp;' => ' '));

?
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

artistsinhawaii

Quote from: Aditya Mooley on September 21, 2005, 12:18:51 PM

Just to make sure, is the line 2891 in functions.inc.php is exactly like

$chars = strtr($CONFIG['forbiden_fname_char'], array('&amp;' => '&', '&quot;' => '"', '&lt;' => '<', '&gt;' => '>', '&nbsp;' => ' '));

?

Yes, mine is identical.

Dennis
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

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

Nibbler

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

Aditya Mooley

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
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

Nibbler

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

artistsinhawaii

#19
Quote from: Aditya Mooley on September 21, 2005, 01:37:43 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
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.