[PATCH consfigurator v2 3/6] add #'valid-hostname-p
Sean Whitton
spwhitton at spwhitton.name
Thu Mar 10 21:57:16 GMT 2022
Hello,
Thanks for sorting this function out -- I'll use it to enforce the new
prerequisite data conventions in addition to your usage in this series.
On Wed 09 Mar 2022 at 08:28pm -04, David Bremner wrote:
> diff --git a/src/package.lisp b/src/package.lisp
> index d1c5836..ea2c580 100644
> --- a/src/package.lisp
> +++ b/src/package.lisp
> @@ -106,6 +106,7 @@
> #:words
> #:unwords
> #:noop
> + #:starts-with-string
> #:symbol-named
> #:memstring=
> #:define-simple-error
Looks like this hunk shouldn't be here.
> diff --git a/src/util.lisp b/src/util.lisp
> index f0ca5cb..79d9d0b 100644
> --- a/src/util.lisp
> +++ b/src/util.lisp
> @@ -742,3 +742,16 @@ Does not currently establish a PAM session."
> (when-let ((output-stream (stream->output-stream stream)))
> (when (open-stream-p output-stream)
> (funcall function output-stream)))))
> +
> +
> +;;;; Hostnames
> +
> +(defun valid-hostname-p (string)
> + "Test whether STRING looks like a valid hostname."
How about adding "as defined by RFCs 952 and 1123."
> diff --git a/tests/util.lisp b/tests/util.lisp
> index bffda68..6b5cb62 100644
> --- a/tests/util.lisp
> +++ b/tests/util.lisp
> @@ -17,3 +17,33 @@
> (deftest version<.4 (version< "1.a.1" "1.1") t)
>
> (deftest version<.5 (version< "1..1" "1.1") t)
> +
> +;; without domain
> +(deftest valid-hostname-p.1 (valid-hostname-p "localhost") t)
> +
> +(deftest valid-hostname-p.2 (valid-hostname-p "host.example.com") t)
> +
> +;; case insensitive check
> +(deftest valid-hostname-p.3 (valid-hostname-p "host.Example.Com") t)
> +
> +;; "total length too long"
What are the quotation marks here? I think a typo?
> +(deftest valid-hostname-p.4
> + (valid-hostname-p (format nil "~{~A~^.~}"
> + (make-list 128 :initial-element "a"))) nil)
> +
> +;; label too long
> +(deftest valid-hostname-p.5
> + (valid-hostname-p (strcat (make-string 64 :initial-element #\a) ".com"))
> + nil)
Would be good to use the same method to construct the string in both of
these. I find the MAKE-STRING one preferable.
--
Sean Whitton
More information about the sgo-software-discuss
mailing list