diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2011-09-09 19:21:38 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2011-09-09 19:21:38 +0800 |
commit | 829556eed648d7ccf27b0e4bdd6326d068634636 (patch) | |
tree | 992523e322e1ac7e2fb4e33d8b4d9de323646d9e | |
parent | 33911d57c5ea97682cc3a733a3e05057fe039224 (diff) | |
download | pttbbs-829556eed648d7ccf27b0e4bdd6326d068634636.tar pttbbs-829556eed648d7ccf27b0e4bdd6326d068634636.tar.gz pttbbs-829556eed648d7ccf27b0e4bdd6326d068634636.tar.bz2 pttbbs-829556eed648d7ccf27b0e4bdd6326d068634636.tar.lz pttbbs-829556eed648d7ccf27b0e4bdd6326d068634636.tar.xz pttbbs-829556eed648d7ccf27b0e4bdd6326d068634636.tar.zst pttbbs-829556eed648d7ccf27b0e4bdd6326d068634636.zip |
reject esc_star in signature files
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5394 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/include/proto.h | 1 | ||||
-rw-r--r-- | pttbbs/mbbsd/edit.c | 1 | ||||
-rw-r--r-- | pttbbs/mbbsd/kaede.c | 22 |
3 files changed, 24 insertions, 0 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index 472008d4..c3ae6878 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -335,6 +335,7 @@ void out_lines(const char *str, int line, int col); #define HAVE_EXPAND_ESC_STAR int expand_esc_star(char *buf, const char *src, int szbuf); void strip_ansi_movecmd(char *s); +void strip_esc_star(char *s); /* lovepaper */ int x_love(void); diff --git a/pttbbs/mbbsd/edit.c b/pttbbs/mbbsd/edit.c index 76e96464..5b14d31e 100644 --- a/pttbbs/mbbsd/edit.c +++ b/pttbbs/mbbsd/edit.c @@ -1797,6 +1797,7 @@ browse_sigs: for (i = 0; i < MAX_SIGLINES && fgets(buf, sizeof(buf), fs); i++) { strip_ansi_movecmd(buf); + strip_esc_star(buf); fputs(buf, fp); } fclose(fs); diff --git a/pttbbs/mbbsd/kaede.c b/pttbbs/mbbsd/kaede.c index 446a5303..c692b282 100644 --- a/pttbbs/mbbsd/kaede.c +++ b/pttbbs/mbbsd/kaede.c @@ -54,6 +54,28 @@ strip_ansi_movecmd(char *s) { } } +void +strip_esc_star(char *s) { + int len; + while (*s) { + char *esc = strstr(s, ESC_STR "*"); + if (!esc) + return; + len = strlen(esc); + // 3: ESC * [a-z] + if (len < 3) { + *esc = 0; + return; + } + if (isalpha(esc[2])) { + memmove(esc, esc + 3, len - 3 + 1); + } else { + // Invalid esc_star. Remove esc instead. + memmove(esc, esc + 1, len - 1 + 1); + } + } +} + char * Ptt_prints(char *str, size_t size, int mode) { |