Index: ossp-pkg/lmtp2nntp/00TODO RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/00TODO,v rcsdiff -q -kk '-r1.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/00TODO,v' 2>/dev/null --- 00TODO 2001/08/23 08:18:26 1.15 +++ 00TODO 2001/08/27 13:45:53 1.16 @@ -2,6 +2,7 @@ M=NNNN im Sendmail ergaenzen (weil Postfix gar nix hat) durch -l Commandline options fuer Maximum Message Size +use "RFC1918-like" private Domainnames for @example.com (check which name is registered) whatsup draufleiten dmalloc FIXMEs Index: ossp-pkg/lmtp2nntp/msg.c RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/msg.c,v rcsdiff -q -kk '-r1.9' '-r1.10' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/msg.c,v' 2>/dev/null --- msg.c 2001/08/23 09:12:30 1.9 +++ msg.c 2001/08/27 13:45:53 1.10 @@ -39,7 +39,7 @@ { if (msg == NULL) return; - /*FIXME what about non-graceful aborts? */ + if (msg->azEnvgroups != NULL) free(msg->azEnvgroups); if (msg->cpMsg != NULL) @@ -99,7 +99,7 @@ /* split message into header and body */ if (str_parse(msg->cpMsg, "m/((?:.*?)\\n)\\n(.*)$/s", &cpHeaders, &msg->cpBody) <= 0) - return MSG_ERR_SPLITSPLITBODY; + return MSG_ERR_SPLITHEADBODY; /* replace envelope From w/o colon by X-F: pseudotag. This eliminates the * special case of having one header, which is really an embedded @@ -110,19 +110,14 @@ memcpy(cpHeaders, "X-F:", 4); /* unwrap header lines */ - /*FIXME poor man's s///g simulator as current str library doesn't support //global substitution */ + /* poor man's s///g simulator as current str library doesn't support global substitution */ while (str_parse(cpHeaders, "s/(.*?)\\n[ \\t]+(.*)/$1 $2/s", &cpRem) > 0) { free(cpHeaders); cpHeaders = cpRem; } /* split header lines into names and values */ - /*FIXME str enhancement requests and bugs to be fixed */ - /*FIXME - fix bug "not" [^...] working */ - /*FIXME - improve str_parse(foo, "...", &foo) should free foo() on it's own */ - /*FIXME - add "global" in s/search/replace/g (see above "unwrap hader lines") */ - while (str_parse(cpHeaders, "m/^([\\w-]+?:)[ \\t]*(.*?)[ \\t]*\\n(.*)/s", - &cpName, &cpValue, &cpRem) > 0) { + while (str_parse(cpHeaders, "m/^([\\w-]+?:)[ \\t]*([^\\n]*?)[ \\t]*\\n(.*)/s", &cpName, &cpValue, &cpRem) > 0) { free(cpHeaders); cpHeaders = cpRem; argz_add(&msg->azHeaders, &msg->asHeaders, cpName); @@ -194,7 +189,7 @@ return MSG_ERR_MEM; } argz_add(&msg->azHeaders, &msg->asHeaders, "Path:"); - argz_add(&msg->azHeaders, &msg->asHeaders, "not-for-mail"); /*FIXME */ + argz_add(&msg->azHeaders, &msg->asHeaders, "not-for-mail"); return MSG_OK; } @@ -205,6 +200,7 @@ char *cpRem; char **aHeaders; int i; + int o; char *cpCut; char *cpWrap; char c; @@ -248,36 +244,47 @@ } free(aHeaders); - /* fold headers */ + /* fold headers + * + * A logical line is split into one or more physical '\n'-terminated + * lines. The physical line is never longer than WRAPAT characters. This + * includes the folded data and the header name + colon + space for the + * first line and WRAPUSING string prefix for all other lines. Leading and + * trailing blanks of folded lines are removed while blanks inside the + * line are preserved. The header is never left alone in a physical line. + * Fragments exceeding WRAPAT characters without having a blank as a + * splitting point are forcibly cut at a non-blank character. + */ cp = NULL; while ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) != NULL) { - if (strlen(cp) >= WRAPAT) { + if (strlen(cp) > WRAPAT) { cpRem = cp; cpWrap = NULL; - while (strlen(cpRem) >= WRAPAT) { - for (i = WRAPAT; i >= 1 && (cpRem[i] != ' ') && (cpRem[i] != '\t'); i--); - if (i == 0) - i = WRAPAT; /* sorry, hard cut at non-whitespace */ - if (i < WRAPAT) - i++; /* we don't care about the whitespace itself */ - cpCut = str_dup(cpRem, i); - /*FIXME 1.) continue searching downwards skipping all whitespaces and 2.) as we know the length replace str_dup/ strcat/ free with strncat only */ - if (cpWrap == NULL) { - if ((cpWrap = (char *)malloc(strlen(cpCut)+strlen(WRAPUSING)+1)) == NULL) - return MSG_ERR_MEM; - *cpWrap = '\0'; - } - else { - if ((cpWrap = (char *)realloc(cpWrap, strlen(cpWrap)+strlen(cpCut)+strlen(WRAPUSING)+1)) == NULL) - return MSG_ERR_MEM; - strcat(cpWrap, WRAPUSING); - } - strcat(cpWrap, cpCut); - free(cpCut); + for (o = 0; (cpRem[o] != ':') && (cpRem[o] != '\0'); o++); /* offset name so at least one char of value remains in first line */ + o += 2; /* skip ": " */ + while ((strlen(cpRem) + (cpWrap == NULL ? 0 : strlen(WRAPUSING))) > WRAPAT) { + for (i = WRAPAT - 1 - (cpWrap == NULL ? 0 : strlen(WRAPUSING)); (i >= o) && !isblank(cpRem[i]); i--); + if (i < o) + i = WRAPAT - 1 - (cpWrap == NULL ? 0 : strlen(WRAPUSING) - 1); /* sorry, forced cut at non-blank */ + cpCut = cpRem; cpRem += i; + for (; (isblank(*cpRem) && (*cpRem != '\0')); cpRem++); /* skip next lines leading blanks */ + for (; (i >= o) && isblank(cpCut[i-1]); i--); /* chop off this lines trailing blanks */ + if (i >= o) { /* only keep line fragment if some non-blanks inside */ + if (cpWrap == NULL) { + if ((cpWrap = (char *)malloc(i+strlen(WRAPUSING)+1)) == NULL) + return MSG_ERR_MEM; + *cpWrap = '\0'; + o = 1; + } + else { + if ((cpWrap = (char *)realloc(cpWrap, strlen(cpWrap)+i+strlen(WRAPUSING)+1)) == NULL) + return MSG_ERR_MEM; + strcat(cpWrap, WRAPUSING); + } + strncat(cpWrap, cpCut, i); + } } - for (i = 0; i < strlen(cpRem) && ((cpRem[i] == ' ') || (cpRem[i] == '\t')); i++); - cpRem += i; if (strlen(cpRem) > 0) { if ((cpWrap = (char *)realloc(cpWrap, strlen(cpWrap)+strlen(cpRem)+strlen(WRAPUSING)+1)) == NULL) return MSG_ERR_MEM; @@ -374,7 +381,7 @@ str = "MSG: no description"; if (rc == MSG_OK ) str = "MSG: no error"; else if (rc == MSG_ERR_MEM ) str = "MSG: memory"; - else if (rc == MSG_ERR_SPLITSPLITBODY ) str = "MSG: split into header and body failed"; + else if (rc == MSG_ERR_SPLITHEADBODY ) str = "MSG: split into header and body failed"; else if (rc == MSG_ERR_SPLITLEN ) str = "MSG: header is too short"; else if (rc == MSG_ERR_SPLITMISSINGFROM ) str = "MSG: header is missing 'From ' envelope"; else if (rc == MSG_ERR_SPLITIDNONE ) str = "MSG: header is missing 'Message-ID'"; Index: ossp-pkg/lmtp2nntp/msg.h RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/msg.h,v rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/Attic/msg.h,v' 2>/dev/null --- msg.h 2001/08/14 14:42:41 1.3 +++ msg.h 2001/08/27 13:45:53 1.4 @@ -25,7 +25,7 @@ typedef enum { MSG_OK, MSG_ERR_MEM, - MSG_ERR_SPLITSPLITBODY, + MSG_ERR_SPLITHEADBODY, MSG_ERR_SPLITLEN, MSG_ERR_SPLITMISSINGFROM, MSG_ERR_SPLITIDNONE, Index: ossp-pkg/lmtp2nntp/test/run.sh RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/test/Attic/run.sh,v rcsdiff -q -kk '-r1.9' '-r1.10' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/test/Attic/run.sh,v' 2>/dev/null --- run.sh 2001/08/23 07:58:44 1.9 +++ run.sh 2001/08/27 13:45:53 1.10 @@ -43,7 +43,7 @@ { newmsg lmtp cat /tmp/testmessage \ - | ../lmtp2nntp -t /tmp/tracing -d $1 -g $2 -h dev16 -h dev16.de.cw.net -h 141.1.23.116 $3 >/dev/null; echo $? + | ../lmtp2nntp -t /tmp/tracing -d $1 -g $2 -h dev16 $3 >/dev/null; echo $? echo ../lmtp2nntp -t /tmp/tracing -d $1 -g $2 -h dev16 $3 # cat /tmp/testmessage \ # | ../lmtp2nntp -t /tmp/tracing -d $1 -g $2 -h dev16 $3 >/dev/null; echo $? Index: ossp-pkg/lmtp2nntp/test/testmessage.vialmtp RCS File: /v/ossp/cvs/ossp-pkg/lmtp2nntp/test/Attic/testmessage.vialmtp,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/lmtp2nntp/test/Attic/testmessage.vialmtp,v' 2>/dev/null --- testmessage.vialmtp 2001/08/23 07:58:44 1.2 +++ testmessage.vialmtp 2001/08/27 13:45:53 1.3 @@ -4,10 +4,15 @@ RCPT To: RCPT To: DATA -Date: Tue, 14 Aug 2001 14:51:48 +0200 (CEST) +Date: Tue, 26 Aug 2001 14:51:48 +0200 (CEST) Message-Id: <200108141251.f7ECpmn74812@dev.de.cw.net> From: Thomas Lotterer -Newsgroups: fu,bar,quux,fuzel,nasen,baer +X-Wraptest1: 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 +X-Wraptest2: 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 +X-Wraptest3: the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG! +X-Wraptest4: thequickbrownfoxjumpsoverthelazydog.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.thequickbrownfoxjumpsoverthelazydog.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.thequickbrownfoxjumpsoverthelazydog.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.thequickbrownfoxjumpsoverthelazydog.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.thequickbrownfoxjumpsoverthelazydog.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.thequickbrownfoxjumpsoverthelazydog.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.thequickbrownfoxjumpsoverthelazydog.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG! +X-Wraptest5: the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG! +X-Wraptest6: the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. the quick brown fox jumps over the lazy dog. THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG! Subject: lmtp2nntp testmessage.viasendmail ..