fix base64 decoding

master
leitner 20 years ago
parent bffb1dab90
commit f3c6288559

@ -110,6 +110,7 @@ int main(int argc,char* argv[]) {
/* skip to "^begin " */ /* skip to "^begin " */
for (;;) { for (;;) {
if ((l=buffer_getline(&filein,line,(sizeof line)-1))==0 && line[l]!='\n') { if ((l=buffer_getline(&filein,line,(sizeof line)-1))==0 && line[l]!='\n') {
hiteof:
if (state!=BEFOREBEGIN) { if (state!=BEFOREBEGIN) {
if (mode!=MIME) { if (mode!=MIME) {
buffer_puts(buffer_1,"premature end of file in line "); buffer_puts(buffer_1,"premature end of file in line ");
@ -190,6 +191,10 @@ foundfilename:
continue; continue;
} else if (str_start(line,"Content-Disposition: ")) { } else if (str_start(line,"Content-Disposition: ")) {
char* c=strstr(line,"filename="); char* c=strstr(line,"filename=");
if (!c) {
if ((l=buffer_getline(&filein,line,(sizeof line)-1))==0 && line[l]!='\n') goto hiteof;
c=strstr(line,"filename=");
}
if (c) { if (c) {
mode=MIME; mode=MIME;
filename[0]=0; filename[0]=0;
@ -351,15 +356,14 @@ invalidpart:
continue; continue;
} else { } else {
unsigned long scanned,x; unsigned long scanned,x;
char tmp[300]; char tmp[1000];
switch (mode) { switch (mode) {
case MIME: case MIME:
switch (mimeenc) { switch (mimeenc) {
case BASE64: x=scan_base64(line,tmp,&scanned); break; case BASE64: x=scan_base64(line,tmp,&scanned); break;
case QP: x=scan_quotedprintable(line,tmp,&scanned); break; case QP: x=scan_quotedprintable(line,tmp,&scanned); break;
default: default:
buffer_putsflush(buffer_2,"MIME encoding NONE?!\n"); break;
exit(0);
} }
if (line[x]) x=0; if (line[x]) x=0;
break; break;

Loading…
Cancel
Save