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"""
|
"""return data for file"""
|
||||||
if msg.file.filepath:
|
if msg.file.filepath:
|
||||||
fpath = os.path.abspath(msg.file.filepath)
|
fpath = os.path.abspath(msg.file.filepath)
|
||||||
|
fpath = pathlib.PurePath(fpath).as_uri()
|
||||||
else:
|
else:
|
||||||
fpath = 'does_not_exists'
|
fpath = 'does_not_exists'
|
||||||
|
|
||||||
return {'msg': self.url_pat.sub('(' +
|
return {'msg': self.url_pat.sub('(' + fpath + ') ' + msg.file.title,
|
||||||
pathlib.PurePath(fpath).as_uri() +
|
msg.text),
|
||||||
') ' + msg.file.title, msg.text),
|
|
||||||
'nick': self._get_symbol('file')}
|
'nick': self._get_symbol('file')}
|
||||||
|
|
||||||
def _msg(self, msg):
|
def _msg(self, msg):
|
||||||
@@ -381,16 +381,16 @@ class StaticHtmlReporter(Reporter):
|
|||||||
"""return data for file"""
|
"""return data for file"""
|
||||||
if msg.file.filepath:
|
if msg.file.filepath:
|
||||||
fpath = os.path.abspath(msg.file.filepath)
|
fpath = os.path.abspath(msg.file.filepath)
|
||||||
|
fpath = pathlib.PurePath(fpath).as_uri()
|
||||||
else:
|
else:
|
||||||
fpath = 'does_not_exists'
|
fpath = 'does_not_exists'
|
||||||
|
|
||||||
_, ext = os.path.splitext(fpath)
|
_, ext = os.path.splitext(fpath)
|
||||||
if ext.lower() in ('.png', '.jpg', '.jpeg', '.gif'):
|
if ext.lower() in ('.png', '.jpg', '.jpeg', '.gif'):
|
||||||
url = ('<img src="' + pathlib.PurePath(fpath).as_uri() +
|
url = ('<img src="' + fpath + '" height="300" alt="' +
|
||||||
'" height="300" alt="' + msg.file.title + '">')
|
msg.file.title + '">')
|
||||||
else:
|
else:
|
||||||
url = ('<a href="' + pathlib.PurePath(fpath).as_uri() +
|
url = ('<a href="' + fpath + '">' + msg.file.title + '</a>')
|
||||||
'">' + msg.file.title + '</a>')
|
|
||||||
|
|
||||||
return {'msg': self.url_pat.sub(url, msg.text),
|
return {'msg': self.url_pat.sub(url, msg.text),
|
||||||
'nick': self._get_symbol('file')}
|
'nick': self._get_symbol('file')}
|
||||||
|
|||||||
Reference in New Issue
Block a user