Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow lowercase encoding specifiers in mime words

  • Loading branch information...
commit 7c1f34715651fb53fa0f7946d3bfd2f3a5defbfe 1 parent 45b727d
@andris9 authored
Showing with 13 additions and 6 deletions.
  1. +3 −3 README.md
  2. +2 −2 lib/mimelib.js
  3. +1 −1  package.json
  4. +7 −0 test/mimelib.js
View
6 README.md
@@ -51,7 +51,7 @@ For example:
Becomes with UTF-8 and Quoted-printable encoding
- =?UTF-8?q?See_on_=C3=B5hin_test?=
+ =?UTF-8?Q?See_on_=C3=B5hin_test?=
### decodeMimeWord
@@ -63,7 +63,7 @@ Decodes a string from mime encoded word format (see also `encodeMimeWord`)
For example
- mimelib.decodeMimeWord("=?UTF-8?q?See_on_=C3=B5hin_test?=");
+ mimelib.decodeMimeWord("=?UTF-8?Q?See_on_=C3=B5hin_test?=");
will become
@@ -163,7 +163,7 @@ Parses mime-words into UTF-8 strings
For example:
- mimelib.parseMimeWords("Hello: =?UTF-8?q?See_on_=C3=B5hin_test?=");
+ mimelib.parseMimeWords("Hello: =?UTF-8?Q?See_on_=C3=B5hin_test?=");
Results in
View
4 lib/mimelib.js
@@ -295,7 +295,7 @@ module.exports.mimeFunctions = {
var fromCharset, encoding, match;
- match = str.match(/^\=\?([\w_\-]+)\?([QB])\?([^\?]+)\?\=$/i);
+ match = str.match(/^\=\?([\w_\-]+)\?([QqBb])\?([^\?]+)\?\=$/i);
if(!match){
return convert(str, toCharset);
}
@@ -321,7 +321,7 @@ module.exports.mimeFunctions = {
str = str.
replace(/(=\?[^?]+\?[QqBb]\?[^?]+\?=)\s+(?==\?[^?]+\?[QqBb]\?[^?]+\?=)/g, "$1").
- replace(/\=\?([\w_\-]+)\?([QB])\?[^\?]+\?\=/g, (function(mimeWord, charset, encoding){
+ replace(/\=\?([\w_\-]+)\?([QqBb])\?[^\?]+\?\=/g, (function(mimeWord, charset, encoding){
curCharset = charset + encoding;
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "mimelib",
"description": "MIME functions to encode/decode e-mails etc.",
- "version": "0.2.10",
+ "version": "0.2.11",
"author" : "Andris Reinman",
"homepage":"http://github.com/andris9/mimelib",
"maintainers":[
View
7 test/mimelib.js
@@ -9,6 +9,13 @@ exports["Quoted printable"] = {
test.done();
},
+ "parseMimeWords example": function(test){
+ test.equal("Hello: See on õhin test", mimelib.parseMimeWords("Hello: =?UTF-8?q?See_on_=C3=B5hin_test?="));
+ test.equal("=?UTF-8?Q?See_on_=C3=B5hin_test?=", mimelib.encodeMimeWord("See on õhin test"));
+ test.equal("See on õhin test", mimelib.decodeMimeWord("=?UTF-8?q?See_on_=C3=B5hin_test?="));
+ test.done();
+ },
+
"Don't wrap between encoded chars": function(test){
var wrapped = "a__________________________",
wrappedEncoded = "a=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=\r\n=5F=5F";
Please sign in to comment.
Something went wrong with that request. Please try again.