@@ -52,35 +52,35 @@ char *spamify_small(char *input)
52
52
53
53
char * spamify_replacedomain (char * input , char * antispamdomain )
54
54
{
55
- /* replace everything after the @-letter in the email address */
56
- int newlen = strlen (input ) + strlen (set_antispam_at );
57
- int domainlen = strlen (antispamdomain );
58
-
59
55
char * atptr = strchr (input , '@' );
56
+
57
+ if (atptr ) {
58
+ /* replace everything after the @-letter in the email address */
59
+ int domainlen = strlen (antispamdomain );
60
+ struct Push buff ;
61
+ int in_ascii = TRUE, esclen = 0 ;
60
62
61
- if (domainlen > 0 ) {
62
- newlen = newlen + domainlen ;
63
- }
63
+ INIT_PUSH (buff );
64
64
65
- if (atptr ) {
66
- char * newbuf = malloc (newlen );
67
- int index = atptr - input ;
68
- /* copy the part before the @ */
69
- memcpy (newbuf , input , index );
70
- /* append _at_ */
71
- memcpy (newbuf + index , set_antispam_at , strlen (set_antispam_at ));
72
- if (domainlen > 0 ) {
73
- /* append the new domain */
74
- strcpy (newbuf + index + strlen (set_antispam_at ), antispamdomain );
75
- }
76
- else {
77
- /* append the part after the @ */
78
- strcpy (newbuf + index + strlen (set_antispam_at ), input + index + 1 );
79
- }
80
- /* correct the pointer and free the old */
81
- free (input );
82
- return newbuf ;
65
+ for (; * input ; input ++ ) {
66
+ if (set_iso2022jp ) {
67
+ iso2022_state (input , & in_ascii , & esclen );
68
+ }
69
+ if (in_ascii == TRUE && * input == '@' ) {
70
+ PushString (& buff , set_antispam_at );
71
+ if (domainlen > 0 ) {
72
+ /* append the new domain */
73
+ PushString (& buff , antispamdomain );
74
+ break ;
75
+ }
76
+ }
77
+ else {
78
+ PushByte (& buff , * input );
79
+ }
80
+ }
81
+ RETURN_PUSH (buff );
83
82
}
83
+
84
84
/* weird email, bail out */
85
85
return input ;
86
86
}
@@ -252,9 +252,9 @@ void getname(char *line, char **namep, char **emailp)
252
252
char * c2 = strchr (line , '>' );
253
253
if (c2 != NULL ) {
254
254
c = c2 + 1 ;
255
- for (i = 0 , len = NAMESTRLEN - 1 ; * c && * c != '\n' && i < len ; c ++ )
255
+ for (i = 0 , len = NAMESTRLEN - 1 ; * c && * c != '\n' && i < len ; c ++ ) {
256
256
name [i ++ ] = * c ;
257
-
257
+ }
258
258
comment_fnd = 1 ;
259
259
}
260
260
}
0 commit comments