Merge lp:~schplurtz/terminator/cmf into lp:terminator/trunk

Proposed by Schplurtz le déboulonné
Status: Merged
Merged at revision: 1575
Proposed branch: lp:~schplurtz/terminator/cmf
Merge into: lp:terminator/trunk
Diff against target: 29 lines (+13/-4)
1 file modified
terminatorlib/terminal.py (+13/-4)
To merge this branch: bzr merge lp:~schplurtz/terminator/cmf
Reviewer Review Type Date Requested Status
Terminator Pending
Review via email: mp+254356@code.launchpad.net

Description of the change

Hi

I found some problems with file drag and drop in terminator. This merge request fixes them.

Dropping multiple files from filemanager into terminator does not work at all :
when multiple files are dragged from a file manager and dropped in terminator, their filenames
are sent to the terminal as a single sh string enclosed in ' '. More exactly, their file://
URL are sent to the terminal, except for the first filename where file:// is stripped.

Current quoting that just surrounds filenames with ' can't handle filename that contain '.
The solution is: surround filename with '. and then, if there are ' in filename, for each
of them, close the string with a ', add \', and reopen the string with '. example :
that's true! -> 'that'\''s true!' which is a valid sh string

It also fixes LP#1311481 .

Regards,
Schplurtz

To post a comment you must log in.
Revision history for this message
Stephen Boddy (stephen-j-boddy) wrote :

Thanks for the contribution.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'terminatorlib/terminal.py'
--- terminatorlib/terminal.py 2015-03-02 21:02:57 +0000
+++ terminatorlib/terminal.py 2015-03-27 05:29:44 +0000
@@ -1010,12 +1010,21 @@
1010 dbg('drag data received of type: %s' % selection_data.type)1010 dbg('drag data received of type: %s' % selection_data.type)
1011 if gtk.targets_include_text(drag_context.targets) or \1011 if gtk.targets_include_text(drag_context.targets) or \
1012 gtk.targets_include_uri(drag_context.targets):1012 gtk.targets_include_uri(drag_context.targets):
1013 # copy text to destination1013 # copy text with no modification yet to destination
1014 txt = selection_data.data.strip(' ')1014 txt = selection_data.data
1015 if txt[0:7] == 'file://':1015 if txt[0:7] == 'file://':
1016 txt = "'%s'" % urllib.unquote(txt[7:])1016 # It is a list of crlf terminated file:// URL. let's iterate
1017 # over all elements.
1018 str=''
1019 for fname in txt.split( "\r\n" ):
1020 dbg('drag data fname: %s' % fname)
1021 if fname == '':
1022 break # last elem is empty since each URL is terminated bye crlf
1023 fname = "'%s'" % urllib.unquote(fname[7:].replace( "'", '\'\\\'\''))
1024 str += fname + ' '
1025 txt=str
1017 else:1026 else:
1018 txt = txt.split('\n')[0]1027 txt = txt.strip(' ').split('\n')[0]
1019 for term in self.terminator.get_target_terms(self):1028 for term in self.terminator.get_target_terms(self):
1020 term.feed(txt)1029 term.feed(txt)
1021 return1030 return