aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-22 21:38:16 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-22 21:38:16 +0000
commit5a2eef4971d2209c986589dabc0489ebf07587a9 (patch)
treecf3a2be05ae6547ce14cc7c6f0aa2021d3771bda /read.c
parent7d9f4162b65729ec0a1223a1051f0292dec0e975 (diff)
downloadmandoc-5a2eef4971d2209c986589dabc0489ebf07587a9.tar.gz
mandoc-5a2eef4971d2209c986589dabc0489ebf07587a9.tar.zst
mandoc-5a2eef4971d2209c986589dabc0489ebf07587a9.zip
Traditional roff(7) explicitly allows certain control characters
in the input stream (SOH, STX, ETX, ENQ, ACK, BEL, BS) for specific purposes (leaders, backspace, delimiters, .tr), but making sure these don't leak through to the output is tricky, so mark them as unsupported for now.
Diffstat (limited to 'read.c')
-rw-r--r--read.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/read.c b/read.c
index 8580f8de..0f79bed6 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.113 2015/01/22 19:26:50 schwarze Exp $ */
+/* $Id: read.c,v 1.114 2015/01/22 21:38:16 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -215,6 +215,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"unsupported feature",
"input too large",
+ "unsupported control character",
"unsupported roff request",
"unsupported table syntax",
"unsupported table option",
@@ -369,9 +370,8 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
if (c & 0x80) {
if ( ! (curp->filenc && preconv_encode(
&blk, &i, &ln, &pos, &curp->filenc))) {
- mandoc_vmsg(MANDOCERR_BADCHAR,
- curp, curp->line, pos,
- "0x%x", c);
+ mandoc_vmsg(MANDOCERR_CHAR_BAD, curp,
+ curp->line, pos, "0x%x", c);
ln.buf[pos++] = '?';
i++;
}
@@ -383,8 +383,10 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
*/
if (c == 0x7f || (c < 0x20 && c != 0x09)) {
- mandoc_vmsg(MANDOCERR_BADCHAR, curp,
- curp->line, pos, "0x%x", c);
+ mandoc_vmsg(c == 0x00 || c == 0x04 ||
+ c > 0x0a ? MANDOCERR_CHAR_BAD :
+ MANDOCERR_CHAR_UNSUPP,
+ curp, curp->line, pos, "0x%x", c);
i++;
ln.buf[pos++] = '?';
continue;
@@ -440,7 +442,7 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
if ( ! (isascii(c) &&
(isgraph(c) || isblank(c)))) {
- mandoc_vmsg(MANDOCERR_BADCHAR, curp,
+ mandoc_vmsg(MANDOCERR_CHAR_BAD, curp,
curp->line, pos, "0x%x", c);
i += 2;
ln.buf[pos++] = '?';