diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -138,6 +138,10 @@ class manifest(revlog): 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 @@ class manifest(revlog): 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 @@ class manifest(revlog): 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]]