Exemplo n.º 1
0
            def __init__(self, config, formatter, feed):
                self.formatter=formatter
                self.feed=feed

                folder=config['folder']
                if config['feeds-in-folders']:
                    name = string.strip(self.feed.name).decode('utf-8')
                    segments = name.split(u'·')
                    folder=mailfolder_join(
                        folder,
                        *(safefilenames.makesafe(seg.encode('utf-8'))
                          for seg in segments)
                        )
                    log.chatty('Storing to Maildir', config['maildir'],
                               folder
                               and 'folder '+folder
                               or 'default folder')
                dir = config['maildir']
                if folder is not None:
                    dir = os.path.join(dir, '.'+folder)
                self.dir = dir
Exemplo n.º 2
0
 def test_empty(self):
     self.failUnlessEqual(safefilenames.makesafe(''), '')
Exemplo n.º 3
0
 def test_attacks(self):
     self.failUnlessEqual(safefilenames.makesafe('../../etc/passwd'), 'etc_passwd')
Exemplo n.º 4
0
 def test_valid(self):
     self.failUnlessEqual(safefilenames.makesafe('abc0+42-99XYZ'), 'abc0+42-99XYZ')
Exemplo n.º 5
0
 def test_leadingUnderscoresNotRemoved(self):
     self.failUnlessEqual(safefilenames.makesafe('___foo'), '___foo')
Exemplo n.º 6
0
 def test_trailingUnderscoresNotRemoved(self):
     self.failUnlessEqual(safefilenames.makesafe('foo___'), 'foo___')
Exemplo n.º 7
0
 def test_trailingBadCharsRemoved(self):
     self.failUnlessEqual(safefilenames.makesafe('foo!!!'), 'foo')
Exemplo n.º 8
0
 def test_leadingBadCharsRemoved(self):
     self.failUnlessEqual(safefilenames.makesafe('!!!foo'), 'foo')
Exemplo n.º 9
0
 def test_intermixed(self):
     self.failUnlessEqual(safefilenames.makesafe('foo/Bar.baz'), 'foo_Bar_baz')
Exemplo n.º 10
0
 def test_knownBadWithUnderscoresHidden(self):
     self.failUnlessEqual(safefilenames.makesafe(' ./,\\_\n_\r!\0'), '___')
Exemplo n.º 11
0
 def test_knownBad(self):
     self.failUnlessEqual(safefilenames.makesafe(' ./,\\\n\r!\0'), '')