PDA

View Full Version : Upload error with a '


Absynthe
06-05-2006, 10:41 PM
I have noticed that pictures with a " ' " in it name are moved with a bad name file in the images directory eg :

"foo's.jpg" will go to "images/foo\'s.jpg"

To fix that, replace line 182 of 'admin/new_image.php'

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

by

if(move_uploaded_file($_FILES['userfile']['tmp_name'], stripslashes($uploadfile))) {

line 253

$thumbnail = $filnamn;

by

$thumbnail = stripslashes($filnamn);

and in 'admin/images_edit.php' line 202

echo "<li><a href=\"../index.php?showimage=$id\"><img src='../thumbnails/thumb_$image' align='left' hspace='3' /></a>

by

echo "<li><a href=\"../index.php?showimage=$id\"><img src=\"../thumbnails/thumb_$image\" align='left' hspace='3' /></a>

Regards.

Connie
06-06-2006, 06:57 AM
congratulation! You found something very special!!!! :confused:

it is not a good idea at all to change the code because of stupid special character in filenames

it is a better idea to use filenames without special characters, like we recommend here and there and everywhere

this stupid windows-misbehaviour of accepting everything as part of a filename is in collision with operation systems and common sense

if you feel so clever you would have taken into considering that manipulating the code will not be update-conform and curing a stupidity with another stupidity is not very intelligent

sorry for my harsh words, but it must be said...

now I feel better

Absynthe
06-06-2006, 08:59 AM
I'm sorry but as a developper you have to take care of special cases to make the use of your program easier.

Perhaps you are right but it doesn't cost anything and will avoid to non expert users a PHP errors they certainly won't understand.

And if you don't want specials characters in filenames, why don't you replace them by an underscore during the upload stage ?

se.nsuo.us
06-06-2006, 09:04 AM
And if you don't want specials characters in filenames, why don't you replace them by an underscore during the upload stage ?
A very valid point I would say....

Joe[y]
06-06-2006, 09:09 AM
absynthe - i see the sense behind what you are doing. but Connie and other members of the team have much more experience with this so i trust them when they say in the long-term it is better to simply encourage valid filenames... pixelpost is open source so any changes you want to make yourself you are totally free to do with your own brance of the program.

Connie
06-06-2006, 09:16 AM
And if you don't want specials characters in filenames, why don't you replace them by an underscore during the upload stage ?

maybe just because I trusted too much in common sense ;=)

Joe[y]
06-06-2006, 09:19 AM
i quite like the underscore idea.

@connie - users could say it is common sense for us to offer a solution.

se.nsuo.us
06-06-2006, 09:38 AM
Something like str_replace(array('&', '"', '<', '>'),"_",$filename) should do the trick, one could add as many characters to the array() as one wished

Joe[y]
06-06-2006, 09:48 AM
Something like str_replace(array('&', '"', '<', '>'),"_",$filename) should do the trick, one could add as many characters to the array() as one wished

how would you add a ' to that array?

se.nsuo.us
06-06-2006, 09:53 AM
This way - array('&', '"', '<', '>', "'")

Connie
06-06-2006, 10:28 AM
']

@connie - users could say it is common sense for us to offer a solution.

yes, but there is common sense for users as well and I am tired of hearing "you must take care of me" because "I do not want to think myself"...

that runs me crazy. Everybody deposits his brains somewhere and cries "fire" when something happens...
we are also not able to protect everybody from drinking boiling hot chocolate ;=)

Absynthe
06-06-2006, 10:46 AM
Connie, the common sens for a developper is to do like users don't have any.

yes, but there is common sense for users as well and I am tired of hearing "you must take care of me" because "I do not want to think myself"...

In this case it's me who thinks for others so I don't see where is the problem. I gave you the fixed code so now it's up to you to include it or not.

But stop hiding you behind the common sens, for a developper it's strongly ridiculous.

Connie
06-06-2006, 02:25 PM
I'm not hiding myself behind anything, I am annoyed by some things sometimes

I appreciate your suggestions but I do not like to hear "you must... so that others must not...." that is too easy...

I am in that business for a long time now and so you get tired sometimes, can't you understand that?

Joe[y]
06-06-2006, 02:48 PM
is there any reason why we should swap bad characters for underscores? seems good to me... but i don't want to put it in cvs if there are reasons i shouldn't which i overlooked.

Connie
06-06-2006, 07:17 PM
as far as I assume, there is nothing against that
but we must discuss what are "bad characters"

space for sure, semicolon, dot, comma...

umlauts?

Absynthe
06-06-2006, 09:52 PM
Glad to hear that.

I propose all the characters non alpha numeric and space.

GeoS
06-07-2006, 09:03 AM
As Connie wrote there is no sense to put such filenames especially that some non-windows systems doesnt like such mess. Idea with converting it to alphanum strings with dots is the best.

raminia
06-07-2006, 01:53 PM
Thank you Absynthe for the bug report :)

Absynthe
06-07-2006, 03:27 PM
You're welcome :)