Mercurial > public > mercurial-scm > hg-stable
diff mercurial/manifest.py @ 3607:f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 01 Nov 2006 17:56:55 +0100 |
parents | 53e843840349 |
children | abaee83ce0a6 |
line wrap: on
line diff
--- a/mercurial/manifest.py Tue Oct 31 18:10:23 2006 -0800 +++ b/mercurial/manifest.py Wed Nov 01 17:56:55 2006 +0100 @@ -138,6 +138,10 @@ return "".join([struct.pack(">lll", d[0], d[1], len(d[2])) + d[2] \ for d in x ]) + def checkforbidden(f): + if '\n' in f or '\r' in f: + raise RevlogError(_("'\\n' and '\\r' disallowed in filenames")) + # if we're using the listcache, make sure it is valid and # parented by the same node we're diffing against if not changed or not self.listcache or not p1 or \ @@ -145,6 +149,9 @@ files = map.keys() files.sort() + for f in files: + checkforbidden(f) + # if this is changed to support newlines in filenames, # be sure to check the templates/ dir again (especially *-raw.tmpl) text = ["%s\000%s%s\n" % (f, hex(map[f]), map.flags(f)) for f in files] @@ -153,6 +160,8 @@ else: addlist = self.listcache + for f in changed[0]: + checkforbidden(f) # combine the changed lists into one list for sorting work = [[x, 0] for x in changed[0]] work[len(work):] = [[x, 1] for x in changed[1]]