Implement ipv6 hostname support in .pgpass rules.

An hostname could be written [::1] in .pgass, without having to escape the
colon characters, and with a proper enclosing in square brackets, as common
for ipv6 addresses.

Fixes #837.
This commit is contained in:
Dimitri Fontaine 2018-11-10 21:01:30 +01:00
parent 656bf85075
commit a6ef7a56a9

View File

@ -14,8 +14,14 @@
(defrule pgpass-escaped-char (and #\\ (or #\\ #\:))
(:lambda (c) (second c)))
(defrule pgpass-ipv6-hostname (and #\[
(+ (or (digit-char-p character) ":"))
#\])
(:lambda (ipv6) (text (second ipv6))))
(defrule pgpass-entry (or "*"
(+ (or pgpass-escaped-char
(+ (or pgpass-ipv6-hostname
pgpass-escaped-char
(pgpass-char-p character))))
(:lambda (e) (text e)))