[PATCH 2/9] Re: Replace 2 regexes with a single one

Nicolas Sebrecht nicolas.s-dev at laposte.net
Wed Apr 27 16:32:34 UTC 2011


On Wed, Apr 27, 2011 at 09:54:34AM +0200, Sebastian Spaeth wrote:
> On Tue, 26 Apr 2011 18:54:31 +0200, Nicolas Sebrecht <nicolas.s-dev at laposte.net> wrote:
> > >      def getfolderfilename(self, foldername):
> > > -        foldername = re.sub('/\.$', '/dot', foldername)
> > > -        foldername = re.sub('^\.$', 'dot', foldername)
> > > +        """Return the full path of the status file"""
> > > +        # replace with 'dot' if final path name is '.'
> > > +        foldername = re.sub('(^|\/)\.$','\\1dot', foldername)
> > >          return os.path.join(self.directory, foldername)
> > 
> > Why are dots a problem only at the _end_ of the foldername?
> 
> The code and the behavior had already been there and it had puzzled me
> too (especially as it was without any comment). That's why I added one
> code comment as to what the regexp does, but it might be worthwhile to
> add even more explanation to it:
> 
> Because we would be trying to create a file called
> "/mailbox/foldername/." and in unix filesystems, "." in a directory
> already has a very special meaning and is not possible filename, so it
> is being replaced with a literal "dot". IMAP mailboxes on the other hand
> can often have just a "." as a name.

It sucks. Well, not you comment which is pretty sensible but our
behaviour sucks. How could we even support folder creation on IMAP
server with such rules some day?

I think we should simply ignore/skip "." folder names and warn.

-- 
Nicolas Sebrecht



More information about the OfflineIMAP-project mailing list