Skip to content
Snippets Groups Projects
Commit c431854c authored by deuce's avatar deuce
Browse files

Make a bunch of REgExps case insentitive and use whitepsace instead of

literal space for boundary detection.
parent 0acb4d6f
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ function count_attachments(hdr, body) ...@@ -20,7 +20,7 @@ function count_attachments(hdr, body)
return(0); return(0);
if(CT.search(/multipart\/[^\s;]*/i)!=-1) { if(CT.search(/multipart\/[^\s;]*/i)!=-1) {
var bound=CT.match(/;[ \r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/); var bound=CT.match(/;[\s\r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/i);
bound[1]=regex_escape(bound[1]); bound[1]=regex_escape(bound[1]);
re=new RegExp ("--"+bound[1]+"-{0,2}",""); re=new RegExp ("--"+bound[1]+"-{0,2}","");
msgbits=body.split(re); msgbits=body.split(re);
...@@ -63,7 +63,7 @@ function mime_decode(hdr, body) ...@@ -63,7 +63,7 @@ function mime_decode(hdr, body)
return(Message); return(Message);
} }
if(CT.search(/multipart\/[^\s;]*/i)!=-1) { if(CT.search(/multipart\/[^\s;]*/i)!=-1) {
var bound=CT.match(/;[ \r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/); var bound=CT.match(/;[\s\r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/i);
bound[1]=regex_escape(bound[1]); bound[1]=regex_escape(bound[1]);
re=new RegExp ("--"+bound[1]+"-{0,2}"); re=new RegExp ("--"+bound[1]+"-{0,2}");
msgbits=body.split(re); msgbits=body.split(re);
...@@ -144,7 +144,7 @@ function decode_body(TE, heads, body) ...@@ -144,7 +144,7 @@ function decode_body(TE, heads, body)
tmp=tmp[1]; tmp=tmp[1];
else { else {
if(TE!=undefined) { if(TE!=undefined) {
tmp=TE.match(/content-transfer-encoding: ([^;\r\n]*)/); tmp=TE.match(/content-transfer-encoding: ([^;\r\n]*)/i);
if(tmp!=undefined) if(tmp!=undefined)
tmp=tmp[1]; tmp=tmp[1];
} }
...@@ -152,7 +152,7 @@ function decode_body(TE, heads, body) ...@@ -152,7 +152,7 @@ function decode_body(TE, heads, body)
} }
else { else {
if(TE!=undefined) { if(TE!=undefined) {
tmp=TE.match(/content-transfer-encoding: ([^;\r\n]*)/); tmp=TE.match(/content-transfer-encoding: ([^;\r\n]*)/i);
if(tmp!=undefined) if(tmp!=undefined)
tmp=tmp[1]; tmp=tmp[1];
} }
...@@ -201,7 +201,7 @@ function mime_get_attach(hdr, body, filename) ...@@ -201,7 +201,7 @@ function mime_get_attach(hdr, body, filename)
return(undefined); return(undefined);
} }
if(CT.search(/multipart\/[^\s;]*/i)!=-1) { if(CT.search(/multipart\/[^\s;]*/i)!=-1) {
var bound=CT.match(/;[ \r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/); var bound=CT.match(/;[\s\r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/i);
bound[1]=regex_escape(bound[1]); bound[1]=regex_escape(bound[1]);
re=new RegExp ("--"+bound[1]+"-{0,2}"); re=new RegExp ("--"+bound[1]+"-{0,2}");
msgbits=body.split(re); msgbits=body.split(re);
...@@ -243,7 +243,7 @@ function mime_get_cid_attach(hdr, body, cid) ...@@ -243,7 +243,7 @@ function mime_get_cid_attach(hdr, body, cid)
return(undefined); return(undefined);
} }
if(CT.search(/multipart\/[^\s;]*/i)!=-1) { if(CT.search(/multipart\/[^\s;]*/i)!=-1) {
var bound=CT.match(/;[ \r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/); var bound=CT.match(/;[\s\r\n]*boundary="{0,1}([^";\r\n]*)"{0,1}/i);
bound[1]=regex_escape(bound[1]); bound[1]=regex_escape(bound[1]);
re=new RegExp ("--"+bound[1]+"-{0,2}"); re=new RegExp ("--"+bound[1]+"-{0,2}");
msgbits=body.split(re); msgbits=body.split(re);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment