From 5af22b61a2cc20244e1ff28526b0600fe8c020ac Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Wed, 3 Sep 2003 07:05:58 +0000 Subject: [PATCH] prep_code() now strips high-ascii chars and removes any non-alphanumeric chars if the length (after stripping invalid chars) is greater than LEN_CODE (8). --- src/sbbs3/scfg/scfg.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sbbs3/scfg/scfg.c b/src/sbbs3/scfg/scfg.c index daf70cba11..c7f1841c32 100644 --- a/src/sbbs3/scfg/scfg.c +++ b/src/sbbs3/scfg/scfg.c @@ -1991,12 +1991,19 @@ char* prep_code(char *str) char tmp[1024]; int i,j; - for(i=j=0;str[i];i++) - if(str[i]>' ' && str[i]!='*' && str[i]!='?' + for(i=j=0;str[i] && i<sizeof(tmp);i++) + if(str[i]>' ' && !(str[i]&0x80) && str[i]!='*' && str[i]!='?' && strchr(ILLEGAL_FILENAME_CHARS,str[i])==NULL) tmp[j++]=str[i]; tmp[j]=0; strcpy(str,tmp); + if(j>=LEN_CODE) { /* Extra chars? Strip symbolic chars */ + for(i=j=0;str[i];i++) + if(isalnum(str[i])) + tmp[j++]=str[i]; + tmp[j]=0; + strcpy(str,tmp); + } return(str); } -- GitLab