Fix uri list parsing
This commit is contained in:
parent
2a197bb8b8
commit
79db010653
@ -96,7 +96,7 @@ class ClipboardObject:
|
|||||||
format = mime.choose_most_significant(self._formats.keys())
|
format = mime.choose_most_significant(self._formats.keys())
|
||||||
if format == 'text/uri-list':
|
if format == 'text/uri-list':
|
||||||
data = self._formats['text/uri-list'].get_data()
|
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 uri.scheme == 'file':
|
||||||
if os.path.exists(uri.path):
|
if os.path.exists(uri.path):
|
||||||
format = mime.get_for_file(uri.path)
|
format = mime.get_for_file(uri.path)
|
||||||
|
@ -76,7 +76,7 @@ class ClipboardService(dbus.service.Object):
|
|||||||
cb_object = self._objects[str(object_path)]
|
cb_object = self._objects[str(object_path)]
|
||||||
|
|
||||||
if format_type == 'XdndDirectSave0':
|
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
|
format.owns_disk_data = True
|
||||||
cb_object.add_format(format)
|
cb_object.add_format(format)
|
||||||
elif on_disk and cb_object.get_percent() == 100:
|
elif on_disk and cb_object.get_percent() == 100:
|
||||||
|
@ -183,7 +183,8 @@ class ClipboardMenu(Palette):
|
|||||||
|
|
||||||
transfer_ownership = False
|
transfer_ownership = False
|
||||||
if format == 'text/uri-list':
|
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:
|
else:
|
||||||
if data['ON_DISK']:
|
if data['ON_DISK']:
|
||||||
file_path = urlparse.urlparse(data['DATA']).path
|
file_path = urlparse.urlparse(data['DATA']).path
|
||||||
|
@ -91,6 +91,15 @@ def choose_most_significant(mime_types):
|
|||||||
logging.debug('Returning first: %r.' % mime_types[0])
|
logging.debug('Returning first: %r.' % mime_types[0])
|
||||||
return 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):
|
def _file_looks_like_text(file_name):
|
||||||
f = open(file_name, 'r')
|
f = open(file_name, 'r')
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user