Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mimelib

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mimelib - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

14

doc.md

@@ -62,8 +62,14 @@ mimelib(1) -- MIME functions for Node.JS

mimelib.decodeMimeWord(str [, encoding][, charset]) -> String
mimelib.decodeMimeWord(str) -> String
- `str` (String): String to be encoded
- `encoding` (String): Encoding Q for quoted printable or B (def.) for base64
- `charset` (String): Charset to be used, defaults to UTF-8
- `str` (String): String to be decoded
For example
mimelib.decodeMimeWord("=?UTF-8?q?See_on_=C3=B5hin_test?=");
will become
See on õhin test
## encodeQuotedPrintable

@@ -70,0 +76,0 @@

@@ -292,30 +292,74 @@

var list = addresses.split(","), address, addressArr = [], name, email;
for(var i=0, len=list.length; i<len; i++){
address = list[i].trim();
if(address.match(/[\s"'<>()]/)){ // address with comments (name)
email = false;
address = address.replace(/<([^>]+)>/,function(a,b){
email = b.indexOf("@")>=0 && b;
return email?"":a;
// find qutoed strings
var parts = addresses.split(','), curStr,
curQuote, lastPos, remainder="", str, list = [],
curAddress, address, addressArr = [], name, email, i, len;
// separate quoted text from text parts
for(i=0, len=parts.length; i<len; i++){
str = "";
curStr = (remainder+parts[i]).trim();
curQuote = curStr.charAt(0);
if(curQuote == "'" || curQuote == '"'){
lastPos = curStr.lastIndexOf(curQuote);
if(!lastPos){
remainder = remainder+parts[i]+",";
continue;
}else{
remainder = "";
str = curStr.substring(1, lastPos).trim();
address = curStr.substr(lastPos+1).trim();
}
}else{
address = curStr;
}
list.push({name: str, address: address, original: curStr});
}
// find e-mail addresses and user names
for(i=0, len=list.length; i<len; i++){
curAddress = list[i];
email = false;
name = false;
name = curAddress.name;
address = curAddress.address.replace(/<([^>]+)>/, function(original, addr){
email = addr.indexOf("@")>=0 && addr;
return email ? "" : original;
}).trim();
if(!email){
address = address.replace(/(\S+@\S+)/, function(original, m){
email = m;
return email ? "" : original;
});
address = address.trim();
}
if(!name){
if(email){
name = address.replace(/"/g,"").trim();
}else{ // try brackets
address = address.replace(/\(([^)]+)\)/,function(a,b){
name = b;
email = email.replace(/\(([^)]+)\)/,function(original, n){
name = n;
return "";
});
email = address.indexOf("@")>=0 && address.trim();
}
// just in case something got mixed up
if(!email && name.indexOf("@")>=0){
email = name;
name = false;
if(!name){
name = address.replace(/"/g,"").trim();
}
if(email)
addressArr.push({address:decodeURIComponent(email), name: decodeURIComponent(name)});
}else if(address.indexOf("@")>=0)
addressArr.push({address:address, name:false});
}
// just in case something got mixed up
if(!email && name.indexOf("@")>=0){
email = name;
name = false;
}
if(email)
addressArr.push({address:decodeURIComponent(email), name: decodeURIComponent(name || "")});
}

@@ -322,0 +366,0 @@ return addressArr;

{
"name": "mimelib",
"description": "MIME functions to encode/decode e-mails etc.",
"version": "0.1.2",
"version": "0.1.3",
"author" : "Andris Reinman",

@@ -6,0 +6,0 @@ "homepage":"http://github.com/andris9/mimelib",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc