summaryrefslogtreecommitdiffstats
path: root/mbbsd/stuff.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-12 13:46:21 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-12 13:46:21 +0800
commit0118e623c97c9c61b34820a38feabeab34408e43 (patch)
tree912c7034e7bee684623efae33d6c4c415c059538 /mbbsd/stuff.c
parenta707b3cd704001f58dad2682f1e699f8dbab5bbc (diff)
downloadpttbbs-0118e623c97c9c61b34820a38feabeab34408e43.tar
pttbbs-0118e623c97c9c61b34820a38feabeab34408e43.tar.gz
pttbbs-0118e623c97c9c61b34820a38feabeab34408e43.tar.bz2
pttbbs-0118e623c97c9c61b34820a38feabeab34408e43.tar.lz
pttbbs-0118e623c97c9c61b34820a38feabeab34408e43.tar.xz
pttbbs-0118e623c97c9c61b34820a38feabeab34408e43.tar.zst
pttbbs-0118e623c97c9c61b34820a38feabeab34408e43.zip
- change show_file parameter to assign striping options in a better way.
- also prevents ESC* style escapes in user_play_query, for security reason. (Thanks to Kinra's report on PttSuggest) git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3996 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/stuff.c')
-rw-r--r--mbbsd/stuff.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 7f2ddd04..2349a68d 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -400,7 +400,7 @@ vmsgf(const char *fmt,...)
* @param filename
* @param x
* @param lines
- * @param mode
+ * @param mode: SHOWFILE_*, see modes.h
* @return 失敗傳回 0,否則為 1。
* 2 表示有 PttPrints 碼
*/
@@ -410,6 +410,12 @@ show_file(const char *filename, int y, int lines, int mode)
FILE *fp;
char buf[1024];
int ret = 1;
+ int strpmode = STRIP_ALL;
+
+ if (mode & SHOWFILE_ALLOW_COLOR)
+ strpmode = ONLY_COLOR;
+ if (mode & SHOWFILE_ALLOW_MOVE)
+ strpmode = NO_RELOAD;
if (y >= 0)
move(y, 0);
@@ -418,15 +424,19 @@ show_file(const char *filename, int y, int lines, int mode)
while (fgets(buf, sizeof(buf), fp) && lines--)
{
move(y++, 0);
- // because Ptt_prints escapes are not so often,
- // let's try harder to detect it.
- if (strstr(buf, ESC_STR "*") != NULL)
+ if (mode == SHOWFILE_RAW)
+ {
+ outs(buf);
+ }
+ else if ((mode & SHOWFILE_ALLOW_STAR) && (strstr(buf, ESC_STR "*") != NULL))
{
- outs(Ptt_prints(buf, sizeof(buf), mode));
+ // because Ptt_prints escapes are not so often,
+ // let's try harder to detect it.
+ outs(Ptt_prints(buf, sizeof(buf), strpmode));
ret = 2;
} else {
// ESC is very common...
- strip_ansi(buf, buf, mode);
+ strip_ansi(buf, buf, strpmode);
outs(buf);
}
}
@@ -574,7 +584,7 @@ void
show_helpfile(const char *helpfile)
{
clear();
- show_file((char *)helpfile, 0, b_lines, NO_RELOAD);
+ show_file((char *)helpfile, 0, b_lines, SHOWFILE_ALLOW_ALL);
#ifdef PLAY_ANGEL
if (HasUserPerm(PERM_LOGINOK))
pressanykey_or_callangel();