Menu

#2614 Apostrophe in filename improperly escaped

v4.2.2
open
nobody
None
5
2009-07-02
2009-06-15
Wes Groleau
No

I understand that the single straight quote is a problem for code that needs to interface to SQL.

We need to catch it coming and going and escape it or unescape it.

Doing so can be tricky, especially if one is trying to guess whether another guy's code has already done it or not.

Anyway, there's at least one place where it doesn't work in SVN 5734.

In my census files, I use the location as part of the filename. So, I have a file named media/census/1930-MI-Baraga-L'Anse-21A.jpg

When I try to edit, I get media/census/1930-MI-Baraga-L\\\'Anse-21A.jpg does not exist

I would prefer to have the name be the subtly different ...L’Anse... but I don't know whether my Linux host can handle UTF-8 filenames. Plus, I am often forced to acquire these files on Windows which definitely can't. So I left it as an apostrophe, which probably should be handled somehow. (Murphy's law: If it can happen, it will)

Discussion

  • Gerry Kroll

    Gerry Kroll - 2009-06-16

    Wes:
    Can you be more specific about "when I edit"?

     
  • Wes Groleau

    Wes Groleau - 2009-06-17

    more specific about "when I edit"?

    The file was pre-loaded by FTP. PGV, in media pages, shows the correct filename:
    media/census/1930-MI-Baraga-L'Anse-21A.jpg

    But if I try to change anything about the file, the edit media popup says:
    "media/census/1930-MI-Baraga-L\\\'Anse-21A.jpg does not exist"
    (three back slashes before the apostrophe)

    My workaround is to rename the file (outside of PGV) to
    media/census/1930-MI-Baraga-L’Anse-21A.jpg
    replacing the ASCII apostrophe with a "real" one (U+2019)

    But some users might not be able to do that (or know how).

     
  • Greg Roach

    Greg Roach - 2009-07-01

    I've just submitted a (possibly unrelated) fix to SVN, which was causing media files to be truncated. i.e. I was seeing "'Anse-21A.jpg" instead of "1930-MI-Baraga-L'Anse-21A.jpg".

    With this fix, I am unable to reproduce your problem. If you are still seeing it, please can you elaborate on the steps between "uploading via FTP" and "editing".

    Thanks,

    Greg

     
  • Greg Roach

    Greg Roach - 2009-07-01
    • status: open --> pending
     
  • Wes Groleau

    Wes Groleau - 2009-07-02

    ** SVN 5811 and before:

    I create a file named Monica's_Candy_Striper_Pin.jpg

    I put it in the media directory by FTP.

    I go to http://UniGen.us/PGV/media.php and login as admin.

    Use show all or filter to see:
    media/Monica's_Candy_Striper_Pin.jpg
    which is correct.

    Now say I decide there should be an "awards" directory. I click Edit. The addmedia popup still has the correct filename in it. I type "awards" in the folder box and click Save. The popup now says

    Directory created: media/awards/
    Directory created: media/thumbs/awards/
    Main media file media/Monica\\\'s_Candy_Striper_Pin.jpg does not exist.
    Thumbnail file media/thumbs/Monica\\\'s_Candy_Striper_Pin.jpg does not exist.
    Paste the following ID into your editing fields to reference the newly created record M432
    Update successful

    Go back to media and it still shows the original filename, but for a thumbnail it has a "no media found" box listing the correct _new_ path for the thumbnail.

    Select the new awards dir and Show All. The new filename is shown, the new ID M423, but in red, "The filename entered does not exist."

    Click Edit raw GEDCOM. GEDCOM shows the new filename correctly.

    So the error must be in the creation of the command to move/rename the file. It's putting in three backslashes instead of one. Probably one piece of code saw the apostrophe and put in a backslash. Then another saw a backslash and escaped that, then, ....

    If I make the filename
    Monica’s_Candy_Striper_Pin.jpg instead of
    Monica's_Candy_Striper_Pin.jpg then there's no problem. But some folks will not be able to use that workaround.

    SVN 5814: Behavior is almost the same. The difference is that there is now only one backslash. But it still says that name doesn't exist.

     
  • Wes Groleau

    Wes Groleau - 2009-07-02
    • status: pending --> open
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.