Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SSHD-1164] - fixed parsing of sshd_config "Host" lines to collapse spaces #196

Closed
wants to merge 1 commit into from
Closed

[SSHD-1164] - fixed parsing of sshd_config "Host" lines to collapse spaces #196

wants to merge 1 commit into from

Conversation

alex-sherwin
Copy link
Contributor

@alex-sherwin alex-sherwin commented May 15, 2021

The ssh_config man page defines the format for Host a bit vaguely as:

If more than one pattern is provided, they should be separated by whitespace.

When running the unit test suite that read my ~/.ssh/config file, there was a Host line which had two spaces between some values which failed parsing in MINA, but doesn't cause any problem for OpenSSH.

This PR simply makes the parsing of Host directive values more lenient by removing blank strings from the split values

@tomaswolf
Copy link
Member

When running the unit test suite that read my ~/.ssh/config file

Completely unrelated: I noticed this, too, and I think this is a bug in the test setups. They should never read the real ~/.ssh/config, that may make tests fail depending on what a user's config contains. Tests should always use a mocked/faked home and ~/.ssh directory, and a mocked/faked config with known static content (maybe empty).

This makes it more lenient where there is > 1 space between Host line values
@alex-sherwin
Copy link
Contributor Author

I updated this to only work based on the parsed Host entries so it cannot impact anything else

Copy link
Member

@tomaswolf tomaswolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll rebase and submit.

* @param cs the CharSequence to check, may be null
* @return {@code true} if the CharSequence is null, empty or whitespace only
* @since 2.0
* @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was copied from somewhere. Looks like StringUtils from org.apache.commons.lang, so license-wise OK.

I'll remove the misleading "since" tags and fix the comment.

@tomaswolf
Copy link
Member

I've merged this as commit 267887a.

@tomaswolf tomaswolf closed this May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants