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

Add support for quoted patterns in Host #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mntnorv
Copy link

@mntnorv mntnorv commented Jan 26, 2022

SSH supports Host patterns with spaces between double quotes, like the following:

Host "pattern with spaces"

Add support for parsing and serializing such patterns.

}

// String prints the string representation of the pattern.
func (p Pattern) String() string {
if p.hasWhitespace {
return fmt.Sprintf("\"%s\"", p.str)
Copy link
Owner

Choose a reason for hiding this comment

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

should we do fmt.Sprintf("%q") here?

Copy link
Author

@mntnorv mntnorv Jan 27, 2022

Choose a reason for hiding this comment

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

I don't think so. String() must return a representation that would work in an actual SSH config file, but %q escapes characters like ", \n, \r, \t. And the pattern string:

  • cannot contain ", because of the logic in parseSSHArguments;
  • cannot contain \n, \r, because of how the lexer parses a config;
  • can contain \t (and probably other characters that %q would escape), but they must be left as-is, as they are not escaped in an SSH config.

@mntnorv
Copy link
Author

mntnorv commented Apr 11, 2022

@kevinburke Hey could you review the PR? This has been standing for a long time. I fixed the conflicts that appeared with the 1.2 release.

@kevinburke
Copy link
Owner

Sorry - I don't get paid to maintain this library and need to prioritize paid work. If you need this feature for your work please reach out about a support contract - there's information in the README.

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