diff --git a/services/shell/clipboardobject.py b/services/shell/clipboardobject.py index 86b719c2..8a104ff9 100644 --- a/services/shell/clipboardobject.py +++ b/services/shell/clipboardobject.py @@ -96,7 +96,7 @@ class ClipboardObject: format = mime.choose_most_significant(self._formats.keys()) if format == 'text/uri-list': data = self._formats['text/uri-list'].get_data() - uri = urlparse.urlparse(data.split('\n')[0], 'file') + uri = urlparse.urlparse(mime.split_uri_list(data)[0], 'file') if uri.scheme == 'file': if os.path.exists(uri.path): format = mime.get_for_file(uri.path) diff --git a/services/shell/clipboardservice.py b/services/shell/clipboardservice.py index c8973edc..a99f7be2 100644 --- a/services/shell/clipboardservice.py +++ b/services/shell/clipboardservice.py @@ -76,7 +76,7 @@ class ClipboardService(dbus.service.Object): cb_object = self._objects[str(object_path)] if format_type == 'XdndDirectSave0': - format = Format('text/uri-list', data, on_disk) + format = Format('text/uri-list', data + '\r\n', on_disk) format.owns_disk_data = True cb_object.add_format(format) elif on_disk and cb_object.get_percent() == 100: diff --git a/shell/view/clipboardmenu.py b/shell/view/clipboardmenu.py index 5acd8cca..f6190e41 100644 --- a/shell/view/clipboardmenu.py +++ b/shell/view/clipboardmenu.py @@ -183,7 +183,8 @@ class ClipboardMenu(Palette): transfer_ownership = False if format == 'text/uri-list': - file_path = urlparse.urlparse(data['DATA']).path + uri = mime.split_uri_list(data['DATA'])[0] + file_path = urlparse.urlparse(uri).path else: if data['ON_DISK']: file_path = urlparse.urlparse(data['DATA']).path diff --git a/sugar/objects/mime.py b/sugar/objects/mime.py index 08b26b1a..62a6f539 100644 --- a/sugar/objects/mime.py +++ b/sugar/objects/mime.py @@ -91,6 +91,15 @@ def choose_most_significant(mime_types): logging.debug('Returning first: %r.' % mime_types[0]) return mime_types[0] +def split_uri_list(uri_list): + result = [] + + splitted = uri_list.split('\n') + for uri in splitted: + result.append(uri.strip()) + + return result + def _file_looks_like_text(file_name): f = open(file_name, 'r') try: