mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-08 00:00:54 +03:00
Fix escaping in WildcardHostMatcher (#382)
* Escape '[' and ']' in WildcardHostMatcher * Anchoring regex to match entire string (Fixes #381)
This commit is contained in:
@@ -135,7 +135,7 @@ public class KnownHostMatchers {
|
||||
private final Pattern pattern;
|
||||
|
||||
public WildcardHostMatcher(String hostEntry) {
|
||||
this.pattern = Pattern.compile(hostEntry.replace(".", "\\.").replace("*", ".*").replace("?", "."));
|
||||
this.pattern = Pattern.compile("^" + hostEntry.replace("[", "\\[").replace("]", "\\]").replace(".", "\\.").replace("*", ".*").replace("?", ".") + "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -360,7 +360,7 @@ public class OpenSSHKnownHosts
|
||||
}
|
||||
|
||||
protected String getHostPart() {
|
||||
return hostPart;
|
||||
return hostPart;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user