1 (edited by faris 2010-02-08 16:46:30)

Topic: Problem with "&" in filenames?

I encountered some very strange behaviour with svManager today....

It boiled down to having an "&" in an image filename.

When I tried uploading one or more images with & in the name, although the upload would work and no errors were displayed, if I then went to Images or Customize, I'd get a nice message at the top of the screen saying there was a problem with the format of gallery.xml. (I forgot to note the exact error - sorry. EDIT. It i actually "Notice: XML in g2/gallery.xml is not well-formed. Error: EntityRef: expecting ';' at line:214 column:3944. Rebuild may be necessary".)

Looking at the xml file itself, it contained no picture data - only the config settings. It was not obviously malformed, and loaded with no errors in IE.

Nothing I could do would resolve the problem other than removing all the images and thumbnails manually then uploading again without the files with & in them. e.g. a rebuild didn't help. (I'm guessing, though I didn't try it, that if I was to delete the image and thumbnail that's been uploaded with the & in the file name then maybe a rebuild would work. I'll try is shortly - EDIT -- yes, deleting the file that's been uploaded with the & in the filename then rebuilding solves the problem, though the gallery name and some colour and button settings seem to get defaulted and need changing back)

Even with an exissting gallery containing pics, just trying to add a single image with an & in the name caused all image data to get deleted from the XML file and the error mentioned above.

Could this be looked into please? It seems like an important issue - I'm sure a lot of images that clients are likely to upload are going to have & in the name at some point.

My environment is:
Server: Centos 4 - 32-bit, php 5.1.6
WS: Windows 7, IE8, Sun Java 6 SE 1.6.0_17
Upload settings: Resize on
Example Filename that triggers the problem: "L & O Multi 1.jpg"

Of course I could be wrong about all this, and something else was triggering it, but it seems repeatable here and I can't think what else it might be.



Re: Problem with "&" in filenames?

Your analysis is correct. SvManager does not currently support ampersands in file names. The ampersand has a special meaning in xml and a (different) special meaning in a url so it's a double whammy.

It may be possible to get around this in a future release of svManager, I'll look in to that. I guess at the least that a friendlier error message might help. But for now, sorry, no ampersands.

SvManager apart, I always stick with alphanumerics, hyphens, dots and underscores for any file or folder names that I put up on the web. Then I don't need to worry about any special encoding for things like question mark, slash, plus etc that all have special meanings in a url.


Jack Hardie
SimpleViewer Support Team.

Re: Problem with "&" in filenames?

Excellent. Thanks Jack.

I think the simplest thing would be to have the uploader remove &s from filenames (or replace with a different character in case someone decides to name a file "& &.jpg" or something silly like that and we don't want to end up with "   .jpg" as the filename).

I never use spaces or basically anything non-alphanumeric, but at the end of the day real end-users (i.e. the people who actually use the scripts as opposed to the people who install them) are likely to put almost anything in their filenames and not even think about the consequences ;-)