aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-05-28 14:13:36 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-05-28 14:13:36 +0000
commitceb2fcaa6f0c730bb1f6f843320f7aefd929a1df (patch)
tree138df7ea1ceb153a7a7990b143189b037d8f4b29
parentc5674755e00edf6c1065f3a925690b630f6e64ff (diff)
downloadmandoc-ceb2fcaa6f0c730bb1f6f843320f7aefd929a1df.tar.gz
mandoc-ceb2fcaa6f0c730bb1f6f843320f7aefd929a1df.tar.zst
mandoc-ceb2fcaa6f0c730bb1f6f843320f7aefd929a1df.zip
URL-fragment strings can only contain certain characters.
Fixing HTML syntax violations e.g. in pf.conf(5) and ifconfig(8) reported by Anton Lazarov <lists at wrant dot com>.
-rw-r--r--html.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/html.c b/html.c
index 9ad83e8e..709c43fa 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.229 2018/05/25 20:23:51 schwarze Exp $ */
+/* $Id: html.c,v 1.230 2018/05/28 14:13:36 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -287,10 +287,16 @@ html_make_id(const struct roff_node *n, int unique)
if (buf == NULL)
return NULL;
- /* http://www.w3.org/TR/html5/dom.html#the-id-attribute */
+ /*
+ * In ID attributes, only use ASCII characters that are
+ * permitted in URL-fragment strings according to the
+ * explicit list at:
+ * https://url.spec.whatwg.org/#url-fragment-string
+ */
for (cp = buf; *cp != '\0'; cp++)
- if (*cp == ' ')
+ if (isalnum((unsigned char)*cp) == 0 &&
+ strchr("!$&'()*+,-./:;=?@_~", *cp) == NULL)
*cp = '_';
if (unique == 0)