From 3e52d29d3db263b73e601c30a30d8e687795cce9 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 20 Apr 2020 12:59:26 +0000 Subject: In fragment identifiers, use ~%d for ordinal suffixes, and reserve the character '~' for that purpose. Bug found by validator.w3.org in openssl(1), which contains both a tag "tls1_2" and a second instance of a tag "tls1", which also resulted in "tls1_2", causing a clash. Now, the second instance of "tls1" is rendered as "tls1~2" instead, employing the newly reserved '~'. --- regress/usr.bin/mandoc/man/IP/literal.out_html | 6 +++--- regress/usr.bin/mandoc/man/TP/literal.out_html | 2 +- regress/usr.bin/mandoc/man/TP/vert.out_html | 2 +- regress/usr.bin/mandoc/mdoc/Bd/nested.out_html | 4 ++-- regress/usr.bin/mandoc/mdoc/Sh/tag.out_html | 2 +- usr.bin/mandoc/html.c | 7 ++++--- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/regress/usr.bin/mandoc/man/IP/literal.out_html b/regress/usr.bin/mandoc/man/IP/literal.out_html index 3b9cc429a3c..aa0536e795c 100644 --- a/regress/usr.bin/mandoc/man/IP/literal.out_html +++ b/regress/usr.bin/mandoc/man/IP/literal.out_html @@ -8,7 +8,7 @@ literal text
-
+
 indented
@@ -32,7 +32,7 @@ literal
 text
 
-
+
 indented
@@ -48,7 +48,7 @@ text
   out of indented paragraph
 

regular text

-
+
indented regular text
 indented
diff --git a/regress/usr.bin/mandoc/man/TP/literal.out_html b/regress/usr.bin/mandoc/man/TP/literal.out_html
index 8b818ed8c68..914c7b5c6ef 100644
--- a/regress/usr.bin/mandoc/man/TP/literal.out_html
+++ b/regress/usr.bin/mandoc/man/TP/literal.out_html
@@ -8,7 +8,7 @@ literal
 text
 
-
+
 indented
diff --git a/regress/usr.bin/mandoc/man/TP/vert.out_html b/regress/usr.bin/mandoc/man/TP/vert.out_html
index 1124ed33dd7..4499432b1a5 100644
--- a/regress/usr.bin/mandoc/man/TP/vert.out_html
+++ b/regress/usr.bin/mandoc/man/TP/vert.out_html
@@ -4,6 +4,6 @@
 
text
-
+
text
diff --git a/regress/usr.bin/mandoc/mdoc/Bd/nested.out_html b/regress/usr.bin/mandoc/mdoc/Bd/nested.out_html index bc71c2700f2..9476189599a 100644 --- a/regress/usr.bin/mandoc/mdoc/Bd/nested.out_html +++ b/regress/usr.bin/mandoc/mdoc/Bd/nested.out_html @@ -8,10 +8,10 @@ outer text regular text
text + Bd-indent" id="outer~2"> text (4n)
text + Bd-indent" id="inner~2"> text (2n)
outer text
diff --git a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html index d99c6d4da69..0dd39398470 100644 --- a/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html +++ b/regress/usr.bin/mandoc/mdoc/Sh/tag.out_html @@ -2,7 +2,7 @@
-

+

Text in duplicate description section.

diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c index b95c609ae79..8892009d9f6 100644 --- a/usr.bin/mandoc/html.c +++ b/usr.bin/mandoc/html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: html.c,v 1.140 2020/04/19 15:15:54 schwarze Exp $ */ +/* $OpenBSD: html.c,v 1.141 2020/04/20 12:59:24 schwarze Exp $ */ /* * Copyright (c) 2011-2015, 2017-2020 Ingo Schwarze * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons @@ -381,11 +381,12 @@ html_make_id(const struct roff_node *n, int unique) * permitted in URL-fragment strings according to the * explicit list at: * https://url.spec.whatwg.org/#url-fragment-string + * In addition, reserve '~' for ordinal suffixes. */ for (cp = buf; *cp != '\0'; cp++) if (isalnum((unsigned char)*cp) == 0 && - strchr("!$&'()*+,-./:;=?@_~", *cp) == NULL) + strchr("!$&'()*+,-./:;=?@_", *cp) == NULL) *cp = '_'; if (unique == 0) @@ -405,7 +406,7 @@ html_make_id(const struct roff_node *n, int unique) if (entry->ord > 1) { cp = buf; - mandoc_asprintf(&buf, "%s_%d", cp, entry->ord); + mandoc_asprintf(&buf, "%s~%d", cp, entry->ord); free(cp); } return buf; -- cgit v1.2.3