1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 14:15:23 +02:00

[286671] Dstore shell service interprets < and > sequences

This commit is contained in:
David McKnight 2009-09-28 20:16:08 +00:00
parent dafe09c8c1
commit 31676d2717
5 changed files with 80 additions and 11 deletions

View file

@ -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("&#59;", ";"); //$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);

View file

@ -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("&#38;");
break;
case ';' :
output.append("&#59;");
break;
default :
output.append(currChar);
break;
}
}
return output.toString();
}
private void doPrompt() {
try {

View file

@ -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)

View file

@ -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 &lt; and &gt; 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("&#38;");
break;
case ';' :
output.append("&#59;");
break;
default :
output.append(currChar);
break;
}
}
return output.toString();
}
}

View file

@ -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 &lt; and &gt; 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("&#38;", "&") //$NON-NLS-1$ //$NON-NLS-2$
.replaceAll("&#59;", ";"); //$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