mirror of
https://github.com/gryf/slack-backup.git
synced 2025-12-17 11:30:25 +01:00
Use as_uri only for absolute file paths, not random strings.
This commit is contained in:
@@ -225,12 +225,12 @@ class TextReporter(Reporter):
|
||||
"""return data for file"""
|
||||
if msg.file.filepath:
|
||||
fpath = os.path.abspath(msg.file.filepath)
|
||||
fpath = pathlib.PurePath(fpath).as_uri()
|
||||
else:
|
||||
fpath = 'does_not_exists'
|
||||
|
||||
return {'msg': self.url_pat.sub('(' +
|
||||
pathlib.PurePath(fpath).as_uri() +
|
||||
') ' + msg.file.title, msg.text),
|
||||
return {'msg': self.url_pat.sub('(' + fpath + ') ' + msg.file.title,
|
||||
msg.text),
|
||||
'nick': self._get_symbol('file')}
|
||||
|
||||
def _msg(self, msg):
|
||||
@@ -381,16 +381,16 @@ class StaticHtmlReporter(Reporter):
|
||||
"""return data for file"""
|
||||
if msg.file.filepath:
|
||||
fpath = os.path.abspath(msg.file.filepath)
|
||||
fpath = pathlib.PurePath(fpath).as_uri()
|
||||
else:
|
||||
fpath = 'does_not_exists'
|
||||
|
||||
_, ext = os.path.splitext(fpath)
|
||||
if ext.lower() in ('.png', '.jpg', '.jpeg', '.gif'):
|
||||
url = ('<img src="' + pathlib.PurePath(fpath).as_uri() +
|
||||
'" height="300" alt="' + msg.file.title + '">')
|
||||
url = ('<img src="' + fpath + '" height="300" alt="' +
|
||||
msg.file.title + '">')
|
||||
else:
|
||||
url = ('<a href="' + pathlib.PurePath(fpath).as_uri() +
|
||||
'">' + msg.file.title + '</a>')
|
||||
url = ('<a href="' + fpath + '">' + msg.file.title + '</a>')
|
||||
|
||||
return {'msg': self.url_pat.sub(url, msg.text),
|
||||
'nick': self._get_symbol('file')}
|
||||
|
||||
Reference in New Issue
Block a user