Create filenames with no path separators in them
We use current hostname as the element of the unique file name. Sometimes there is non-/24 zone delegation, {{{ $ host 144.206.233.65 65.233.206.144.in-addr.arpa is an alias for 65.26/64.233.206.144.in-addr.arpa. }}} as per RFC 2317, https://www.rfc-editor.org/rfc/rfc2317.txt So on Un*x systems we may run into having path separator inside the file name. Not good, things will choke. Prevented this by substituting all appeared path separators in the return value. Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru> Tested-at: my MacOSX instance, my FreeBSD instances
This commit is contained in:
parent
0ad8bb25ad
commit
3a807d0f2b
@ -82,6 +82,10 @@ class MaildirFolder(BaseFolder):
|
|||||||
"general", "utime_from_header", False)
|
"general", "utime_from_header", False)
|
||||||
self._utime_from_header = self.config.getdefaultboolean(
|
self._utime_from_header = self.config.getdefaultboolean(
|
||||||
self.repoconfname, "utime_from_header", utime_from_header_global)
|
self.repoconfname, "utime_from_header", utime_from_header_global)
|
||||||
|
# What do we substitute pathname separator in names (if any)
|
||||||
|
self.sep_subst = '-'
|
||||||
|
if os.path.sep == self.sep_subst:
|
||||||
|
self.sep_subst = '_'
|
||||||
|
|
||||||
# Interface from BaseFolder
|
# Interface from BaseFolder
|
||||||
def getfullname(self):
|
def getfullname(self):
|
||||||
@ -286,9 +290,10 @@ class MaildirFolder(BaseFolder):
|
|||||||
:returns: String containing unique message filename"""
|
:returns: String containing unique message filename"""
|
||||||
|
|
||||||
timeval, timeseq = _gettimeseq(date)
|
timeval, timeseq = _gettimeseq(date)
|
||||||
return '%d_%d.%d.%s,U=%d,FMD5=%s%s2,%s'% \
|
uniq_name = '%d_%d.%d.%s,U=%d,FMD5=%s%s2,%s' % \
|
||||||
(timeval, timeseq, os.getpid(), socket.gethostname(),
|
(timeval, timeseq, os.getpid(), socket.gethostname(),
|
||||||
uid, self._foldermd5, self.infosep, ''.join(sorted(flags)))
|
uid, self._foldermd5, self.infosep, ''.join(sorted(flags)))
|
||||||
|
return uniq_name.replace(os.path.sep, self.sep_subst)
|
||||||
|
|
||||||
|
|
||||||
def save_to_tmp_file(self, filename, content):
|
def save_to_tmp_file(self, filename, content):
|
||||||
|
Loading…
Reference in New Issue
Block a user