correctly escape file names when showing them in dialogs. Fixes #7038

This commit is contained in:
Yann Leboulanger 2011-11-06 12:25:41 +01:00
parent c467e44370
commit 4a0b02ac3a
1 changed files with 7 additions and 4 deletions

View File

@ -175,7 +175,8 @@ class FileTransfersWindow:
(file_path, file_name) = os.path.split(file_props['file-name']) (file_path, file_name) = os.path.split(file_props['file-name'])
else: else:
file_name = file_props['name'] file_name = file_props['name']
sectext = '\t' + _('Filename: %s') % file_name sectext = '\t' + _('Filename: %s') % gobject.markup_escape_text(
file_name)
sectext += '\n\t' + _('Size: %s') % \ sectext += '\n\t' + _('Size: %s') % \
helpers.convert_bytes(file_props['size']) helpers.convert_bytes(file_props['size'])
if file_props['type'] == 'r': if file_props['type'] == 'r':
@ -231,7 +232,8 @@ class FileTransfersWindow:
file_name = os.path.basename(file_props['file-name']) file_name = os.path.basename(file_props['file-name'])
else: else:
file_name = file_props['name'] file_name = file_props['name']
sectext = '\t' + _('Filename: %s') % file_name sectext = '\t' + _('Filename: %s') % gobject.markup_escape_text(
file_name)
sectext += '\n\t' + _('Recipient: %s') % jid sectext += '\n\t' + _('Recipient: %s') % jid
if error_msg: if error_msg:
sectext += '\n\t' + _('Error message: %s') % error_msg sectext += '\n\t' + _('Error message: %s') % error_msg
@ -328,7 +330,8 @@ class FileTransfersWindow:
if os.path.exists(file_path): if os.path.exists(file_path):
# check if we have write permissions # check if we have write permissions
if not os.access(file_path, os.W_OK): if not os.access(file_path, os.W_OK):
file_name = os.path.basename(file_path) file_name = gobject.markup_escape_text(os.path.basename(
file_path))
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('Cannot overwrite existing file "%s"' % file_name), _('Cannot overwrite existing file "%s"' % file_name),
_('A file with this name already exists and you do not ' _('A file with this name already exists and you do not '
@ -590,7 +593,7 @@ class FileTransfersWindow:
iter_ = self.model.iter_next(iter_) iter_ = self.model.iter_next(iter_)
def get_send_file_props(self, account, contact, file_path, file_name, def get_send_file_props(self, account, contact, file_path, file_name,
file_desc=''): file_desc=''):
""" """
Create new file_props dict and set initial file transfer properties in it Create new file_props dict and set initial file transfer properties in it
""" """