diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-12-04 16:34:59 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2008-12-04 16:34:59 +0000 |
commit | fb40e7adf35e6b21b0e64e170b71e1a4d2cf5351 (patch) | |
tree | 709633693c524f8f2a224e8031814f910d646925 | |
parent | 7ea64ffd96cef95695a6c74dbf90f76d73fa961d (diff) | |
download | mandoc-fb40e7adf35e6b21b0e64e170b71e1a4d2cf5351.tar.gz |
Character-set validation fixes.
-rw-r--r-- | index.7 | 16 | ||||
-rw-r--r-- | mlg.c | 13 | ||||
-rw-r--r-- | private.h | 3 | ||||
-rw-r--r-- | roff.c | 10 | ||||
-rw-r--r-- | tokens.c | 9 |
5 files changed, 40 insertions, 11 deletions
@@ -21,8 +21,9 @@ and .Nm acts directly on source documents, validating its input and producing a variety of outputs. -.Ss Features -In order to operate properly, +.\" +.Ss Validation +In order to operate sanely, .Nm fully validates its input. This includes, but is not limited to, the following checks: @@ -40,10 +41,19 @@ macros clobbering a pending .Sq \&.Bl scope), .It -predefined characters (such as \\*(>= and \\*q), +predefined characters (such as \\*(>= and \\*q, rendering as \*(>= and \*q, +respectively), .It correctly-ordered document prelude, +.It +sane argument values (such as those for +.Sq \& Dt +or +.Sq \& Sm ) , +.It +and so on. .El +.Pp .\" .Sh ENVIRONMENT The @@ -594,10 +594,6 @@ mlg_rofftoken(void *arg, int space, int value) seq = " "; sz = 6; break; - case (ROFFTok_Null): - seq = ""; - sz = 0; - break; case (ROFFTok_Hyphen): seq = "‐"; sz = 7; @@ -670,13 +666,20 @@ mlg_rofftoken(void *arg, int space, int value) seq = "Nan"; sz = 3; break; + case (ROFFTok_Quote): + seq = """; + sz = 6; + break; + default: + /* TODO: print error. */ + return(0); } if (space && ! ml_nputs(p->mbuf, " ", 1, &res)) return(0); p->pos += res; - if (0 != sz && ! ml_nputs(p->mbuf, seq, sz, &res)) + if ( ! ml_nputs(p->mbuf, seq, sz, &res)) return(0); p->pos += res; @@ -64,7 +64,8 @@ struct md_mbuf { #define ROFFTok_Infty 24 #define ROFFTok_Bar 25 #define ROFFTok_Nan 26 -#define ROFFTok_MAX 27 +#define ROFFTok_Quote 27 +#define ROFFTok_MAX 28 #define ROFF___ 0 #define ROFF_Dd 1 @@ -971,12 +971,20 @@ roffdata(struct rofftree *tree, int space, char *buf) { int tok; + if (0 == *buf) + return(1); + if (-1 == (tok = rofftok_scan(buf))) { roff_err(tree, buf, "invalid character sequence"); return(0); - } else if (ROFFTok_MAX != tok) + } else if (ROFFTok_MAX != tok) { + if (ROFFTok_Null == tok) { /* FIXME */ + buf += 2; + return(roffdata(tree, space, buf)); + } return((*tree->cb.rofftoken) (tree->arg, space != 0, tok)); + } return((*tree->cb.roffdata)(tree->arg, space != 0, tree->cur, buf)); @@ -88,7 +88,12 @@ rofftok_predef(const char *buf) if ('(' == *buf) return(rofftok_defined(++buf)); - /* TODO */ + switch (*buf) { + case ('q'): + return(ROFFTok_Quote); + default: + break; + } return(-1); } @@ -173,6 +178,8 @@ rofftok_scan(const char *buf) return(ROFFTok_Hyphen); case ('*'): return(rofftok_predef(++buf)); + case ('\\'): + return(ROFFTok_MAX); default: break; } |