Closed jeromedalbert closed 5 months ago
@mattbrictson Good point. Because the IPv6 parser still needs a high priority, we need a strict IPv6 regex. Resolv::IPv6::Regex
seems to be the way to go, it is pretty involved in order to catch all the different IPv6 formats, so that should be plenty strict for our needs.
I have updated the PR and description accordingly, and added an extra unit test for the db:22
scenario you mentioned.
Fix for https://github.com/capistrano/sshkit/issues/537.
Solution
IPv6HostParser
. This parser has a high priority in the parser list so IPv6 addresses are not incorrectly picked up and parsed byHostWithPortParser
's simple regex.Resolv::IPv6::Regex
from the stdlib.Notes
My previous solution tweaked the regex of the existing
IPv6HostWithPortParser
, but this resulted in a regression for local hostnames, so I am usingResolv::IPv6::Regex
instead, which should prove more stable. I added an extra unit test to validate the local hostname scenario.