Permalink
Browse files

updated quoteprintable decoding - escape loose equation marks

  • Loading branch information...
1 parent 708ff15 commit b42a0def966691f56e868c8d126b478603d07a1b Andris Reinman committed Jan 6, 2012
Showing with 13 additions and 4 deletions.
  1. +12 −3 mime-functions.js
  2. +1 −1 package.json
View
@@ -190,10 +190,17 @@ this.decodeQuotedPrintable = function(str, mimeWord, charset){
str = str.replace(/\=(\r?\n|\r)/gm,'');
str = str.replace(/\=$/,"");
}
+
+ // if there are some invalid = symbols convert these to quoted-printable
+ // notation, otherwise decodeURICompontent throws an error
+ str = str.replace(/\=(?![a-f0-9]{2})/ig,"=3D");
+
+ // convert quoted-printable to urlencoded
+ str = str.replace(/%/g,'%25').replace(/\=/g,"%");
+
if(charset == "UTF-8"){
- str = decodeURIComponent(str.replace(/%/g,'%25').replace(/\=/g,"%"));
+ str = decodeURIComponent(str);
}else{
- str = str.replace(/%/g,'%25').replace(/\=/g,"%");
if(charset=="ISO-8859-1" || charset=="LATIN1")
str = unescape(str);
else{
@@ -359,8 +366,10 @@ this.parseAddresses = function(addresses){
email = name;
name = false;
}
- if(email)
+
+ if(email){
addressArr.push({address:decodeURIComponent(email), name: decodeURIComponent(name || "")});
+ }
}
return addressArr;
};
View
@@ -1,7 +1,7 @@
{
"name": "mimelib",
"description": "MIME functions to encode/decode e-mails etc.",
- "version": "0.1.8",
+ "version": "0.1.9",
"author" : "Andris Reinman",
"homepage":"http://github.com/andris9/mimelib",
"maintainers":[

0 comments on commit b42a0de

Please sign in to comment.