Skip to content
Snippets Groups Projects
Commit f894ac74 authored by rswindell's avatar rswindell
Browse files

Moved Tracker1's newsutil.js mods into mailutil.js, so they can be used by

mailproc_util.js. Renamed to mail_get_*, and fixed a couple "bugs".
parent d67dc715
No related branches found
No related tags found
No related merge requests found
// mailutil.js
// Parses Internet mail and USENET article header fields
// for use with newsutil.js and mailproc_util.js
// $Id$
//Michael J. Ryan - 2004-04-16 - tracker1(at)theroughnecks.net
// gets the name portion for the "to/from"
function mail_get_name(strIn) {
var reName1 = /[^\"]*\"([^\"]*)\".*/ //quoted name
var reName2 = /(\S[^<]+)\s+<.*/ //unquoted name
var reName3 = /[^<]*<([^@>]+).*/ //first part of <email address>
var reName4 = /([^@]+)*@.*/ //first part of email address
if (reName1.test(strIn)) return strIn.replace(reName1,"$1");
if (reName2.test(strIn)) return strIn.replace(reName2,"$1");
if (reName3.test(strIn)) return strIn.replace(reName3,"$1");
if (reName4.test(strIn)) return strIn.replace(reName4,"$1");
return strIn; //original string
}
//Michael J. Ryan - 2004-04-16 - tracker1(at)theroughnecks.net
// gets the address portion for the "to/from"
function mail_get_address(strIn) {
var reEmail1 = /[^<]*<([^>]+)>.*/
var reEmail2 = /([^@]+@.*)/
if (strIn.match(reEmail1)) return strIn.replace(reEmail1,"$1");
if (strIn.match(reEmail2)) return strIn.replace(reEmail2,"$1");
return null;
}
\ No newline at end of file
......@@ -5,6 +5,8 @@
// $Id$
load("mailutil.js");
RFC822HEADER = 0xb0 // from smbdefs.h
function write_news_header(hdr,writeln)
......@@ -93,8 +95,8 @@ function parse_news_header(hdr, line)
case "to":
case "apparently-to":
case "x-comment-to":
hdr.to = getName(data);
hdr.to_net_addr = getEmail(data);
hdr.to = mail_get_name(data);
hdr.to_net_addr = mail_get_address(data);
break;
case "newsgroups":
hdr.newsgroups=data;
......@@ -103,8 +105,8 @@ function parse_news_header(hdr, line)
hdr.path=data;
break;
case "from":
hdr.from = getName(data);
hdr.from_net_addr = getEmail(data);
hdr.from = mail_get_name(data);
hdr.from_net_addr = mail_get_address(data);
break;
case "organization":
hdr.from_org=data;
......@@ -165,27 +167,3 @@ function parse_news_header(hdr, line)
break;
}
}
//Michael J. Ryan - 2004-04-16 - tracker1(at)theroughnecks.net
// gets the name portion for the "to/from"
function getName(strIn) {
var reName1 = /[^\"]*\"([^\"]*)\".*/ //quoted name
var reName2 = /(\S[^<]+)\s+<.*/ //unquoted name
var reName3 = /[^<]*<([^@>]).*/ //first part of email address
var strName = strIn;
if (reName1.test(strIn)) strName = strIn.replace(reName1,"$1");
else if (reName2.test(strIn)) strName = strIn.replace(reName2,"$1");
else if (reName3.test(strIn)) strName = strIn.replace(reName3,"$1");
return strName; //original string
}
//Michael J. Ryan - 2004-04-16 - tracker1(at)theroughnecks.net
// gets the email portion for the "to/from"
function getEmail(strIn) {
var reEmail1 = /[^<]*<([^>]+)>.*/
var strEmail = strIn;
log("getEmail(" + strEmail + ")");
if (strIn.match(reEmail1)) return strIn.replace(reEmail1,"$1");
return null;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment