1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Bug 486593 - fix encoding of connection names

Change-Id: If7ead4315e3ad3e755ebb06f31520bde28e44c56
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2016-03-09 15:09:25 -05:00
parent 1f92cdd524
commit 9a9aae87ba
2 changed files with 8 additions and 4 deletions

View file

@ -114,14 +114,14 @@ public class RemoteConnection implements IRemoteConnection {
throw new ConnectionExistsException(newName); throw new ConnectionExistsException(newName);
} }
Preferences newPrefs = connectionType.getPreferenceNode().node(newName); Preferences newPrefs = connectionType.getPreferenceNode().node(URLEncoder.encode(newName, "UTF-8"));
Preferences oldPrefs = getPreferences(); Preferences oldPrefs = getPreferences();
for (String key : oldPrefs.keys()) { for (String key : oldPrefs.keys()) {
newPrefs.put(key, oldPrefs.get(key, null)); newPrefs.put(key, oldPrefs.get(key, null));
} }
oldPrefs.removeNode(); oldPrefs.removeNode();
} catch (BackingStoreException e) { } catch (BackingStoreException | UnsupportedEncodingException e) {
RemoteCorePlugin.log(e); RemoteCorePlugin.log(e);
} }

View file

@ -10,7 +10,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.remote.internal.core; package org.eclipse.remote.internal.core;
import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -68,10 +71,11 @@ public class RemoteConnectionType implements IRemoteConnectionType {
// load up existing connections // load up existing connections
try { try {
for (String connectionName : getPreferenceNode().childrenNames()) { for (String nodeName : getPreferenceNode().childrenNames()) {
String connectionName = URLDecoder.decode(nodeName, "UTF-8");
connections.put(connectionName, new RemoteConnection(this, connectionName)); connections.put(connectionName, new RemoteConnection(this, connectionName));
} }
} catch (BackingStoreException e) { } catch (BackingStoreException | UnsupportedEncodingException e) {
RemoteCorePlugin.log(e); RemoteCorePlugin.log(e);
} }
} }