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

Tracker1's mod for parsing the from and to name/address into separate header

fields.
parent a91adadd
No related branches found
No related tags found
No related merge requests found
......@@ -93,7 +93,8 @@ function parse_news_header(hdr, line)
case "to":
case "apparently-to":
case "x-comment-to":
hdr.to=data;
hdr.to = getName(data);
hdr.to_net_addr = getEmail(data);
break;
case "newsgroups":
hdr.newsgroups=data;
......@@ -102,7 +103,8 @@ function parse_news_header(hdr, line)
hdr.path=data;
break;
case "from":
hdr.from=data;
hdr.from = getName(data);
hdr.from_net_addr = getEmail(data);
break;
case "organization":
hdr.from_org=data;
......@@ -163,3 +165,27 @@ 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