summaryrefslogtreecommitdiffstats
path: root/chars.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-01 08:38:56 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-01 08:38:56 +0000
commit8a71696314cb577679e44de0e250aeeb8ec08bd1 (patch)
tree6ce8c5b3d708b18f6dd802cc0213aa65dcedd0a3 /chars.c
parent44ecac209529bca926296c46ec9ba062147bfbe2 (diff)
downloadmandoc-8a71696314cb577679e44de0e250aeeb8ec08bd1.tar.gz
Filter all \N'' values with isprint(). Ok schwarze@.
Diffstat (limited to 'chars.c')
-rw-r--r--chars.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/chars.c b/chars.c
index e4702997..e0bbd35a 100644
--- a/chars.c
+++ b/chars.c
@@ -20,6 +20,7 @@
#endif
#include <assert.h>
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -135,9 +136,11 @@ mchars_res2cp(struct mchars *arg, const char *p, size_t sz)
return(ln->unicode);
}
-
/*
* Numbered character to literal character.
+ * This can only be a printable character (i.e., alnum, punct, space) so
+ * prevent the character from ruining our state (backspace, newline, and
+ * so on).
*/
char
mchars_num2char(const char *p, size_t sz)
@@ -148,15 +151,9 @@ mchars_num2char(const char *p, size_t sz)
return('\0');
i = atoi(p);
- /*
- * FIXME:
- * This is wrong. Anything could be written here!
- * This should be carefully screened for possible characters.
- */
- return(i <= 0 || i > 255 ? '\0' : (char)i);
+ return(isprint(i) ? (char)i : '\0');
}
-
/*
* Special character to string array.
*/
@@ -173,7 +170,6 @@ mchars_spec2str(struct mchars *arg, const char *p, size_t sz, size_t *rsz)
return(ln->ascii);
}
-
/*
* Reserved word to string array.
*/