From: schwarze Date: Tue, 9 Aug 2022 11:21:50 +0000 (+0000) Subject: prevent breakable hyphens in segment identifiers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3cc45a9d38cefca347754ff6ad1ee07b3f5fadb9;p=openbsd prevent breakable hyphens in segment identifiers from being turned into underscores; bug reported by Habert --- diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c index 68db54b54e5..20588aadb56 100644 --- a/usr.bin/mandoc/html.c +++ b/usr.bin/mandoc/html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: html.c,v 1.149 2022/07/06 14:27:55 schwarze Exp $ */ +/* $OpenBSD: html.c,v 1.150 2022/08/09 11:21:50 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze @@ -401,10 +401,13 @@ html_make_id(const struct roff_node *n, int unique) * In addition, reserve '~' for ordinal suffixes. */ - for (cp = buf; *cp != '\0'; cp++) - if (isalnum((unsigned char)*cp) == 0 && + for (cp = buf; *cp != '\0'; cp++) { + if (*cp == ASCII_HYPH) + *cp = '-'; + else if (isalnum((unsigned char)*cp) == 0 && strchr("!$&'()*+,-./:;=?@_", *cp) == NULL) *cp = '_'; + } if (unique == 0) return buf;