diff --git a/exec/load/newsutil.js b/exec/load/newsutil.js index a525ee875c582c0a7cc433090522f19d5fe98a75..2a68d647b76ab2808d23539eaaca24343a43fc61 100644 --- a/exec/load/newsutil.js +++ b/exec/load/newsutil.js @@ -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