1
0
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:
2018-05-05 16:13:13 +02:00
parent 5e7f4740ed
commit 007fe04c08

View File

@@ -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')}