summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2011-08-22 12:48:38 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2011-08-22 12:48:38 +0800
commit3a6a144ad682f5d4be3926676e60182588df49fa (patch)
treed0f7c123b46d76d6651c8385cd6034ba986df584
parent22bb8201118bb815e2fc3a3c955b71fda57bf4b3 (diff)
downloadpttbbs-3a6a144ad682f5d4be3926676e60182588df49fa.tar
pttbbs-3a6a144ad682f5d4be3926676e60182588df49fa.tar.gz
pttbbs-3a6a144ad682f5d4be3926676e60182588df49fa.tar.bz2
pttbbs-3a6a144ad682f5d4be3926676e60182588df49fa.tar.lz
pttbbs-3a6a144ad682f5d4be3926676e60182588df49fa.tar.xz
pttbbs-3a6a144ad682f5d4be3926676e60182588df49fa.tar.zst
pttbbs-3a6a144ad682f5d4be3926676e60182588df49fa.zip
forbid movement ANSI escape sequence in signature files
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5385 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/edit.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c
index 46d01980..25a25976 100644
--- a/pttbbs/mbbsd/edit.c
+++ b/pttbbs/mbbsd/edit.c
@@ -1440,6 +1440,28 @@ quote_strip_ansi_inline(unsigned char *is)
*os = 0;
}
+static int
+process_ansi_movecmd(char *s, int replace) {
+ const char *pattern_movecmd = "ABCDfjHJRu";
+ const char *pattern_ansi_code = "0123456789;,[";
+
+ while (*s) {
+ char *esc = strchr(s, ESC_CHR);
+ if (!esc)
+ return 0;
+ s = ++esc;
+ while (*esc && strchr(pattern_ansi_code, *esc))
+ esc++;
+ if (strchr(pattern_movecmd, *esc)) {
+ if (replace == YEA)
+ *esc = 's';
+ else
+ return 1;
+ }
+ }
+ return 0;
+}
+
static void
do_quote(void)
{
@@ -1795,8 +1817,10 @@ browse_sigs:
if ((fs = fopen(fpath, "r"))) {
fputs("\n--\n", fp);
for (i = 0; i < MAX_SIGLINES &&
- fgets(buf, sizeof(buf), fs); i++)
+ fgets(buf, sizeof(buf), fs); i++) {
+ process_ansi_movecmd(buf, YEA);
fputs(buf, fp);
+ }
fclose(fs);
fpath[i] = ch;
}