#12 better filename quoting

closed
nobody
None
5
2006-02-07
2005-09-03
Anonymous
No

(Submited by Luc.Habert@ens.fr)

The filenames inserted in strings passed to `system',
are not perfectly quoted (a ' or a " (depending on
where the quoting is done) in the filename will defeat
the quoting).

I propose this quoting function :

void quote_filename(const FXString & s,FXString & res) {
size_t len=0;
size_t l=s.length();
for (size_t t=0;t<l;t++) {
if (s[t]=='\'') len+=4; else len++;
}
res.length(len+2);
res[0]='\''; res[len+1]='\'';
size_t u=1;
for (size_t t=0;t<l;t++) {
if (s[t]=='\'') {
res[u]='\'';u++;
res[u]='\\';u++;
res[u]='\'';u++;
res[u]='\'';
} else {
res[u]=s[t];
}
u++;
}
}

Then, FilePanel.cc is to be modified according to the
attached diff.

Discussion

  • Logged In: NO

    Where is the diff? Was is lost or did you forget to attach it?

     
  • Roland Baudin
    Roland Baudin
    2006-02-07

    • status: open --> closed
     
  • Roland Baudin
    Roland Baudin
    2006-02-07

    Logged In: YES
    user_id=629537

    OK, it has been fixed in version 0.88.
    Thanks for the patch!
    RB