fix IPv6 hostname parsing (#1004)

This commit is contained in:
Svante von Erichsen 2025-05-25 01:26:22 +02:00
parent 70f3557670
commit 096992acbc
4 changed files with 9 additions and 8 deletions

View File

@ -61,7 +61,7 @@ __ http://www.quicklisp.org/beta/
When building from sources, you should always build from the current git
HEAD as it's basically the only source that is managed in a way to ensure it
builds aginst current set of dependencies versions.
builds against current set of dependencies versions.
The build system for pgloader uses a Makefile and the Quicklisp Common Lisp
packages distribution system.

View File

@ -44,9 +44,6 @@
;; password looks like '(":" "password")
(list :user username :password (cadr password)))))
(defun hexdigit-char-p (character)
(member character #. (quote (coerce "0123456789abcdefABCDEF" 'list))))
(defrule ipv4-part (and (digit-char-p character)
(? (digit-char-p character))
(? (digit-char-p character))))
@ -55,13 +52,13 @@
(:lambda (ipv4)
(list :ipv4 (text ipv4))))
(defrule ipv6 (and #\[ (+ (or (digit-char-p character) ":")) #\])
(defrule ipv6 (and #\[ (+ (or (hexdigit-char-p character) ":")) #\])
(:lambda (ipv6)
(list :ipv6 (text ipv6))))
;;; socket directory is unix only, so we can forbid ":" on the parsing
;; socket directory is unix only, so we can forbid ":" on the parsing
(defun socket-directory-character-p (char)
(or (member char #.(quote (coerce "/.-_" 'list)))
(or (find char "/.-_")
(alphanumericp char)))
(defrule socket-directory (and "unix:"

View File

@ -65,3 +65,7 @@
(defrule comma-separator (and ignore-whitespace #\, ignore-whitespace)
(:constant ","))
;; Predicates for use in rules can only be called with arity 1.
(defun hexdigit-char-p (character)
(digit-char-p character 16))

View File

@ -15,7 +15,7 @@
(:lambda (c) (second c)))
(defrule pgpass-ipv6-hostname (and #\[
(+ (or (digit-char-p character) ":"))
(+ (or (hexdigit-char-p character) ":"))
#\])
(:lambda (ipv6) (text (second ipv6))))