Fix duplicate character echoing in ProcessShell #870
Merged
+123
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a bug where characters were duplicated when using an interactive shell (e.g., "ping" appearing as "ppiinngg"). The fix involves removing the redundant manual echoing logic from
TtyFilterOutputStream.Problem Description
When using
InteractiveProcessShellFactory, MINA SSHD starts a local process (like/bin/shorcmd.exe) and bridges its I/O streams usingProcessShell.ProcessShellusedTtyFilterOutputStreamto wrap the process's input stream.TtyFilterOutputStreamwas configured to manually echo every character received from the client back to the client's output stream ifPtyMode.ECHOwas enabled (which is common for interactive sessions). However, interactive shells already perform their own echoing. BecauseProcessShelloperates over pipes rather than a real PTY, both the server-side filter and the shell process were echoing the input, leading to doubled characters.Standard SSH implementations (like OpenSSH) do not perform manual echoing in the server for shell sessions; they rely on the TTY or the shell process to handle it.
Solution
The manual echoing mechanism in
TtyFilterOutputStreamhas been removed.PtyMode.ECHOis no longer handled byTtyFilterOutputStream.echoparameter (aTtyFilterInputStream) has been removed fromTtyFilterOutputStreamconstructors.ProcessShellhas been updated to stop passing the echo stream.ProcessShellTestto verify that input is no longer redundantly echoed to the error stream.This ensures that only the underlying shell process handles echoing, which is the correct behavior for this type of shell bridging.
Fixes #469.