From 31676d27176878d37a221d2bb47b85564d3ee842 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Mon, 28 Sep 2009 20:16:08 +0000 Subject: [PATCH] [286671] Dstore shell service interprets < and > sequences --- .../miners/command/CommandMinerThread.java | 16 +++++++---- .../miners/command/OutputHandler.java | 27 +++++++++++++++++- .../shells/DStoreShellOutputReader.java | 7 +++-- .../dstore/shells/DStoreShellThread.java | 28 ++++++++++++++++++- .../dstore/DStoreServiceCommandShell.java | 13 +++++++-- 5 files changed, 80 insertions(+), 11 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java index 0f285acc588..51f92d677ed 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java @@ -21,6 +21,7 @@ * David McKnight (IBM) [249715] [dstore][shells] Unix shell does not echo command * David McKnight (IBM) [153275] [dstore-shells] Ctrl+C does not break remote program * David McKnight (IBM) [284179] [dstore] commands have a hard coded line length limit of 100 characters + * David McKnight (IBM) - [286671] Dstore shell service interprets < and > sequences *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.command; @@ -570,14 +571,19 @@ public class CommandMinerThread extends MinerThread } - - + private String convertSpecialCharacters(String input){ + // needed to ensure xml characters aren't converted in xml layer + String converted = input.replaceAll("&", "&") //$NON-NLS-1$ //$NON-NLS-2$ + .replaceAll(";", ";"); //$NON-NLS-1$//$NON-NLS-2$ + return converted; + } + public void sendInput(String input) { if (!_isDone) { - -// byte[] intoout = input.getBytes(); + String origInput = input; + input = convertSpecialCharacters(input); input.getBytes(); try @@ -626,7 +632,7 @@ public class CommandMinerThread extends MinerThread if (!_isWindows && !_isTTY) { - createObject("input", input); //$NON-NLS-1$ + createObject("input", origInput); //$NON-NLS-1$ } writer.write(input); diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java index acf1f005130..ec9f6cb78eb 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java @@ -16,6 +16,7 @@ * David McKnight (IBM) - [243699] [dstore] Loop in OutputHandler * David McKnight (IBM) [249715] [dstore][shells] Unix shell does not echo command * David McKnight (IBM) - [282919] [dstore] server shutdown results in exception in shell io reading + * David McKnight (IBM) - [286671] Dstore shell service interprets < and > sequences *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.command; @@ -98,7 +99,7 @@ public class OutputHandler extends Handler { * !_isTerminal) { doPrompt(); } } else */ for (int i = 0; i < lines.length; i++) { - String line = lines[i]; + String line = convertSpecialCharacters(lines[i]); _commandThread.interpretLine(line, _isStdError); } @@ -111,6 +112,30 @@ public class OutputHandler extends Handler { finish(); } } + + private String convertSpecialCharacters(String input){ + // needed to ensure xml characters aren't converted in xml layer + + StringBuffer output = new StringBuffer(); + + for (int idx = 0; idx < input.length(); idx++) + { + char currChar = input.charAt(idx); + switch (currChar) + { + case '&' : + output.append("&"); + break; + case ';' : + output.append(";"); + break; + default : + output.append(currChar); + break; + } + } + return output.toString(); + } private void doPrompt() { try { diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellOutputReader.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellOutputReader.java index fd2652ba90e..84c9bb9a737 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellOutputReader.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellOutputReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David McKnight (IBM) - [286671] return null when status is null *******************************************************************************/ package org.eclipse.rse.internal.services.dstore.shells; @@ -90,6 +90,9 @@ public class DStoreShellOutputReader extends AbstractHostShellOutputReader imple e.printStackTrace(); } } + if (_status == null){ + return null; + } if (_status.getValue().equals("done")) //$NON-NLS-1$ { if (!_isErrorReader) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java index 505b19107d1..ca8b8972291 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellThread.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * {Name} (company) - description of contribution. * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup + * David McKnight (IBM) - [286671] Dstore shell service interprets < and > sequences *******************************************************************************/ package org.eclipse.rse.internal.services.dstore.shells; @@ -262,6 +263,7 @@ public class DStoreShellThread if (cmd != null) { + cmd = convertSpecialCharacters(cmd); DataElement commandDescriptor = getSendInputDescriptor(commandElement); if (commandDescriptor != null) { @@ -272,4 +274,28 @@ public class DStoreShellThread } } } + + private String convertSpecialCharacters(String input){ + // needed to ensure xml characters aren't converted in xml layer + + StringBuffer output = new StringBuffer(); + + for (int idx = 0; idx < input.length(); idx++) + { + char currChar = input.charAt(idx); + switch (currChar) + { + case '&' : + output.append("&"); + break; + case ';' : + output.append(";"); + break; + default : + output.append(currChar); + break; + } + } + return output.toString(); + } } diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java index 0a179324b9e..50448d2bd8b 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * David McKnight (IBM) - [202822] cleanup output datalements after use * Martin Oberhuber (Wind River) - [225510][api] Fix OutputRefreshJob API leakage + * David McKnight (IBM) - [286671] Dstore shell service interprets < and > sequences *******************************************************************************/ package org.eclipse.rse.internal.subsystems.shells.dstore; @@ -139,6 +140,13 @@ public class DStoreServiceCommandShell extends ServiceCommandShell return reader.getWorkingDirectory(); } + private String convertSpecialCharacters(String input){ + // needed to ensure xml characters aren't converted in xml layer + String converted = input.replaceAll("&", "&") //$NON-NLS-1$ //$NON-NLS-2$ + .replaceAll(";", ";"); //$NON-NLS-1$//$NON-NLS-2$ + return converted; + } + public void shellOutputChanged(IHostShellChangeEvent event) { IHostOutput[] lines = event.getLines(); @@ -161,7 +169,8 @@ public class DStoreServiceCommandShell extends ServiceCommandShell { output = new RemoteOutput(this, type); } - output.setText(line.getName()); + + output.setText(convertSpecialCharacters(line.getName())); int colonSep = src.indexOf(':'); // line numbers