From 1fefdf21dc99f8e7830e172d231c649ba9ba43a9 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Thu, 25 Nov 2010 09:07:49 +0000 Subject: [PATCH] Bug 236334 - [ssh][encodings] Cannot copy files or folders with turkish or arabic names --- .../services/ssh/files/SftpFileService.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java index 3ce77d995e2..b28946d9fd1 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java @@ -1070,7 +1070,20 @@ public class SftpFileService extends AbstractFileService implements ISshService, Channel channel = null; try { channel=fSessionProvider.getSession().openChannel("exec"); //$NON-NLS-1$ - ((ChannelExec)channel).setCommand(command); + try { + // ChannelExec#setCommand(byte[]) was added in JSch-0.1.38 only + ((ChannelExec) channel).setCommand(command.getBytes(fJSchChannelEncoding)); + } catch (NoSuchMethodError nsm) { + // Fallback for JSch-0.1.37 and below: always decodes in + // Platform Default Encoding! + byte[] bytesDesired = command.getBytes(fJSchChannelEncoding); + String stringToSend = new String(bytesDesired); + byte[] bytesSent = stringToSend.getBytes(); + if (!bytesDesired.equals(bytesSent)) { + throw new UnsupportedEncodingException("Cannot encode for JSch as \"" + fJSchChannelEncoding + "\": " + command); + } + ((ChannelExec) channel).setCommand(new String(bytesDesired)); + } //No user input channel.setInputStream(null);