patch for replacing non-printable chars in filenames

Paul Slootman paul at
Thu Nov 25 10:27:58 GMT 2004

On Tue 23 Nov 2004, Wayne Davison wrote:
> On Tue, Nov 23, 2004 at 05:29:57PM +0100, Paul Slootman wrote:
> > Here's a patch. Opinions?
> I think that a better place to munge the name would be in the
> safe_fname() routine in utils.c (which already munges newlines
> characters into question marks).  The reason I didn't change
> any other characters was because I feared that it would mangle
> foreign filenames that use high-bit characters.  I'd want some
> feedback from such users before accepting such a patch.

Not all filenames that are printed are passed through safe_fname()
AFAICS, e.g. a random piece of code from rsync.c:166 :

                if (verbose > 2) {
                        if (change_uid) {
                                    "set uid of %s from %ld to %ld\n",
                                    fname, (long)st->st_uid, (long)file->uid);
                        if (change_gid) {
                                    "set gid of %s from %ld to %ld\n",
                                    fname, (long)st->st_gid, (long)file->gid);

Note that isprint() will take into account the locale in effect, i.e.
when using the FR_fr locale things like é should be recognized as
printable. At least, under linux that would seem to be the case; from
the NOTE section of isprint's manpage:

    The  details of what characters belong into which class depend on
    the current locale. [...]

setlocale(LC_CTYPE, NULL) probably needs to be called during program
startup, however...

The bug reporter (a frenchman I believe) was agreeable to all non-ASCII
chars being replaced however; that's preferable to having his tty messed
now and again.

Making it depend on whether stdout is a tty may also be useful.

Paul Slootman

More information about the rsync mailing list