From: address parsing problem (READ ME FIRST!)
Forrest J. Cavalier III
mibsoft at epix.net
Wed Sep 13 11:31:54 UTC 2000
>The last test I've done is with a INN 2.2.2 installed on a RedHat
>machine and it seems to work perfectly. I'm going now to make a test
>upgrading INN
>
>on my server to see if this will solve the problem.
With the trace, I think I see the problem. INN 1.7 parses only the
first line of multi-line "From" headers.
- You can replace the cleanfrom.c and recompile 1.7. (diff below)
- If you upgrade, please upgrade to 2.3. The changes between
2.2 and 2.3 are significant.
-----------------------------------------------------------
--- inn-1.5.1/lib/cleanfrom.c Tue Dec 17 05:40:40 1996
+++ inn-2.3.0/lib/cleanfrom.c Mon Aug 21 02:14:43 2000
@@ -1,4 +1,4 @@
-/* $Revision: 1.5 $
+/* $Revision: 1.4 $
**
*/
#include <stdio.h>
@@ -18,23 +18,45 @@
** address (stuff) address
** stuff <address> address
*/
-void
-HeaderCleanFrom(from)
- char *from;
+void HeaderCleanFrom(char *from)
{
- register char *p;
- register char *end;
+ char *p;
+ char *end;
+ int len;
+
+ if ((len = strlen(from)) == 0)
+ return;
+ /* concatenate folded header */
+ for (p = end = from ; p < from + len ;) {
+ if (*p == '\n') {
+ if ((p + 1 < from + len) && ISWHITE(p[1])) {
+ if ((p - 1 >= from) && (p[-1] == '\r')) {
+ end--;
+ *end = p[1];
+ p += 2;
+ } else {
+ *end = p[1];
+ p++;
+ }
+ } else {
+ *end = '\0';
+ break;
+ }
+ } else
+ *end++ = *p++;
+ }
+ if (end != from)
+ *end = '\0';
- /* Do the equivalent of sed's "1q" */
- if ((p = strchr(from, '\n')) != NULL)
+ /* Do pretty much the equivalent of sed's "s/(.*)//g"; */
+ while ((p = strchr(from, LPAREN)) && (end = strchr(p, RPAREN))) {
+ while (*++end)
+ *p++ = *end;
*p = '\0';
+ }
- /* Do pretty much the equivalent of sed's "s/ (.*)//"; doesn't
- * work for "(save (delete this)" but that's okay. */
- if ((p = strchr(from, LPAREN))
- && p > from
- && *--p == ' '
- && (end = strrchr(p, RPAREN))) {
+ /* Do pretty much the equivalent of sed's "s/\".*\"//g"; */
+ while ((p = strchr(from, '"')) && (end = strchr(p, '"'))) {
while (*++end)
*p++ = *end;
*p = '\0';
@@ -46,4 +68,17 @@
*from++ = *p;
*from = '\0';
}
+
+ /* drop white spaces */
+ if ((len = strlen(from)) == 0)
+ return;
+ for (p = end = from ; p < from + len ;) {
+ if (ISWHITE(*p)) {
+ p++;
+ continue;
+ }
+ *end++ = *p++;
+ }
+ if (end != from)
+ *end = '\0';
}
More information about the inn-workers
mailing list