summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2022-08-09 11:21:51 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2022-08-09 11:21:51 +0000
commited5452d0d3687662b5ccef13c773a49a14a0691a (patch)
tree897aa5e0682bc40bf8fe45c98bc42bcbd90ab35c /usr.bin
parent9ee7389d992eee087b6f46b7c52245a0907e0c59 (diff)
prevent breakable hyphens in segment identifiers
from being turned into underscores; bug reported by <Eldred dot fr> Habert
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/html.c9
1 files changed, 6 insertions, 3 deletions
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 <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org>
@@ -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;