commit 5219f09d7703a7f31ed4276d341310c2c24136b4 from: Omar Polo date: Sun Jun 25 09:07:37 2023 UTC fix printing of maintainer' email commit - 61e647965bcff2edb0f718571f2497a563f190a3 commit + 5219f09d7703a7f31ed4276d341310c2c24136b4 blob - 77f8c6984b87b2064b3a8c6431b66eea2ad1c5ad blob + a917129c01f67b1ba34ca69553a06ec6fc5dec7a --- server.c +++ server.c @@ -527,6 +527,41 @@ route_listing(struct env *env, struct client *clt) return (-1); } +static int +print_maintainer(struct client *clt, const char *mail) +{ + int r, in_addr; + + for (in_addr = 0; *mail != '\0'; ++mail) { + if (!in_addr) { + if (clt_putc(clt, *mail) == -1) + return (-1); + if (*mail == '<') + in_addr = 1; + continue; + } + + switch (*mail) { + case '@': + r = clt_puts(clt, " at "); + break; + case '.': + r = clt_puts(clt, " dot "); + break; + case '>': + in_addr = 0; + /* fallthrough */ + default: + r = clt_putc(clt, *mail); + break; + } + if (r == -1) + return (-1); + } + + return (0); +} + int route_port(struct env *env, struct client *clt) { @@ -597,7 +632,9 @@ route_port(struct env *env, struct client *clt) goto err; if (clt_printf(clt, "\n") == -1 || - clt_printf(clt, "Maintainer: %s\n", maintainer) == -1 || + clt_printf(clt, "Maintainer: ") == -1 || + print_maintainer(clt, maintainer) == -1 || + clt_puts(clt, "\n\n") == -1 || clt_printf(clt, "## Description\n") == -1 || clt_printf(clt, "``` %s description\n", stem) == -1 || clt_puts(clt, descr) == -1 ||