Skip to content

Commit

Permalink
improve 'nonbsp' option
Browse files Browse the repository at this point in the history
- replace Unicode NBSPs only in UTF-8 articles
- replace NBSPs also in ISO-8859-* and Windows-125x articles
  • Loading branch information
cnb committed May 1, 2024
1 parent 8221313 commit 0896df5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
29 changes: 20 additions & 9 deletions src/nntpserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2395,18 +2395,29 @@ void command_post(struct var *var)

line[c]=0;

/* Replace UTF-8 non-breaking spaces by normal spaces */
if(var->opt_nonbsp && strstr(line,"\0xC2\0xA0")!=NULL)
{
int i = strlen(line)-2;
while(i>0)
/* Replace non-breaking spaces by normal spaces */
if(var->opt_nonbsp) {
if(stricmp(chrs,"UTF-8")==0 && strstr(line,"\0xC2\0xA0")!=NULL)
{
int i=strlen(line)-2;
while(i>0)
{
if (line[i]==0xC2 && line[i+1]==0xA0)
{
memmove(line+i,line+i+1,strlen(line)-i);
line[i]=' ';
}
i--;
}
}
else if((strnicmp(chrs,"ISO-8859-",9)==0 || strnicmp(chrs,"WINDOWS-125",11)==0) && strchr(line,0xA0)!=NULL)
{
if (line[i]==0xC2 && line[i+1]==0xA0)
int i=strlen(line)-1;
while(i>0)
{
memmove(line+i, line+i+1, strlen(line)-i);
line[i] = ' ';
if(line[i]==0xA0) line[i]=' ';
i--;
}
i--;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/nntpserv.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct var
#define CRLF CR LF

#define SERVER_NAME "JamNNTPd/" PLATFORM_NAME
#define SERVER_VERSION "1.4-c beta 2"
#define SERVER_VERSION "1.4-c beta 3"
#define SERVER_PIDVERSION SERVER_VERSION

#define SOCKIO_TIMEOUT 5*60
Expand Down

0 comments on commit 0896df5

Please sign in to comment.