URI: 
       add function to check server/hostname - gopher-validator - Simple gopher menu validator.
  HTML git clone git://bitreich.org/gopher-validator git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/gopher-validator
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit e4a622665300d0c8c5ce1a4fa6608f6733f3c191
   DIR parent 5ca656215b1e77b7fef4dcf37cd6e429146b9426
  HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat, 10 Aug 2019 20:27:37 +0200
       
       add function to check server/hostname
       
       this check is incomplete, but should cover some cases
       
       Diffstat:
         M gopher-validator.c                  |      38 +++++++++++++++++++++++++++++++
       
       1 file changed, 38 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/gopher-validator.c b/gopher-validator.c
       @@ -130,6 +130,41 @@ warning(const char *fmt, ...)
        }
        
        int
       +isvalidserver(const char *s)
       +{
       +        int colons;
       +
       +        /* IPv6 */
       +        if (*s == '[') {
       +                colons = 0;
       +                s++;
       +                for (; *s; s++) {
       +                        if (*s == ':')
       +                                colons++;
       +                        else if (*s == ']')
       +                                break;
       +                        else if (isxdigit((unsigned char)*s))
       +                                ;
       +                        else
       +                                return 0;
       +                }
       +                if (colons < 2 || *s != ']')
       +                        return 0;
       +        } else {
       +                if (!*s)
       +                        return 0;
       +                for (; *s; s++) {
       +                        if (!isalpha((unsigned char)*s) &&
       +                            !isdigit((unsigned char)*s) &&
       +                            *s != '-' && *s != '.')
       +                                return 0;
       +                }
       +        }
       +
       +        return 1;
       +}
       +
       +int
        edial(const char *host, const char *port)
        {
                struct addrinfo hints, *res, *res0;
       @@ -312,6 +347,9 @@ checkdir(FILE *fp)
                                }
                        }
        
       +                if (!isvalidserver(v.server))
       +                        error("%zu: invalid server: %s\n", linenr, v.server);
       +
                        /* check port, must be numeric and in range, port 0 is allowed:
                        "Appendix:
                        Note: Port corresponds the the TCP Port Number, its value should