summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-03-06 14:58:10 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-03-06 14:58:10 +0000
commit006240c00075748ea6caaf15bc37a67cf3454ee5 (patch)
tree9864f2ada15063349cf04ad6eb983da81229d884
parent6720c2e5aeecf3fc18ed94d21fe39caffaa70f11 (diff)
downloadmandoc-006240c00075748ea6caaf15bc37a67cf3454ee5.tar.gz
URIs need different escaping; reported by reyk@
-rw-r--r--mdoc_markdown.c15
-rw-r--r--regress/mdoc/Rs/allch.out_markdown4
2 files changed, 14 insertions, 5 deletions
diff --git a/mdoc_markdown.c b/mdoc_markdown.c
index ae06201e..1e1f115d 100644
--- a/mdoc_markdown.c
+++ b/mdoc_markdown.c
@@ -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;
diff --git a/regress/mdoc/Rs/allch.out_markdown b/regress/mdoc/Rs/allch.out_markdown
index 7faac2a3..afc6488f 100644
--- a/regress/mdoc/Rs/allch.out_markdown
+++ b/regress/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,