summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-03-06 14:57:45 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-03-06 14:57:45 +0000
commit2825ef4260683368811874245759d9b9c5682366 (patch)
treea56b3629033203f6b1aae908961213d196230dc9
parent70993888bd13d14f8ae848af98978e02e177dbcd (diff)
URIs need different escaping; reported by reyk@
-rw-r--r--regress/usr.bin/mandoc/mdoc/Rs/allch.out_markdown4
-rw-r--r--usr.bin/mandoc/mdoc_markdown.c17
2 files changed, 15 insertions, 6 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Rs/allch.out_markdown b/regress/usr.bin/mandoc/mdoc/Rs/allch.out_markdown
index 7faac2a3cdc..afc6488f819 100644
--- a/regress/usr.bin/mandoc/mdoc/Rs/allch.out_markdown
+++ b/regress/usr.bin/mandoc/mdoc/Rs/allch.out_markdown
@@ -18,7 +18,7 @@ author name,
report name,
number of journal,
volume number,
-uniform resource locator,
+<uniform resource locator>,
page number,
institutional author,
city name,
@@ -40,7 +40,7 @@ author name,
report name,
number of journal,
volume number,
-uniform resource locator,
+<uniform resource locator>,
page number,
institutional author,
city name,
diff --git a/usr.bin/mandoc/mdoc_markdown.c b/usr.bin/mandoc/mdoc_markdown.c
index a75931de634..00f5069f38b 100644
--- a/usr.bin/mandoc/mdoc_markdown.c
+++ b/usr.bin/mandoc/mdoc_markdown.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_markdown.c,v 1.2 2017/03/04 21:41:13 schwarze Exp $ */
+/* $OpenBSD: mdoc_markdown.c,v 1.3 2017/03/06 14:57:44 schwarze Exp $ */
/*
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -220,7 +220,7 @@ static const struct md_act md_acts[MDOC_MAX + 1] = {
{ NULL, NULL, md_post_pc, NULL, NULL }, /* %Q */
{ NULL, md_pre_br, NULL, NULL, NULL }, /* br */
{ NULL, md_pre_Pp, NULL, NULL, NULL }, /* sp */
- { NULL, NULL, md_post_pc, NULL, NULL }, /* %U */
+ { NULL, md_pre_Lk, md_post_pc, NULL, NULL }, /* %U */
{ NULL, NULL, NULL, NULL, NULL }, /* Ta */
{ NULL, NULL, NULL, NULL, NULL }, /* ll */
{ NULL, NULL, NULL, NULL, NULL }, /* ROOT */
@@ -1235,6 +1235,7 @@ static int
md_pre_Lk(struct roff_node *n)
{
const struct roff_node *link, *descr;
+ const unsigned char *s;
if ((link = n->child) == NULL)
return 0;
@@ -1251,8 +1252,16 @@ md_pre_Lk(struct roff_node *n)
} else
md_rawword("<");
- outflags &= ~MD_spc;
- md_word(link->string);
+ for (s = link->string; *s != '\0'; s++) {
+ if (strchr("%)<>", *s) != NULL) {
+ printf("%%%2.2hhX", *s);
+ outcount += 3;
+ } else {
+ putchar(*s);
+ outcount++;
+ }
+ }
+
outflags &= ~MD_spc;
md_rawword(link->next == NULL ? ">" : ")");
return 0;