aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2013-06-01 18:43:13 +0200
committerMatěj Cepl <mcepl@redhat.com>2013-06-01 18:53:12 +0200
commit11513118c01fa09c1d50ad9f9793a5a965ba2ccc (patch)
treeb43263362b23dc752edd1a232fbd5617d8381738
parent326c4a90ace2ccfd5a51ce1090bb466832c88a68 (diff)
downloadparseLDIF-11513118c01fa09c1d50ad9f9793a5a965ba2ccc.tar.gz
Add some missing fields from Thunderbird LDIF.
-rw-r--r--parseLDIF.js33
1 files changed, 26 insertions, 7 deletions
diff --git a/parseLDIF.js b/parseLDIF.js
index 77cf3fb..f28eba5 100644
--- a/parseLDIF.js
+++ b/parseLDIF.js
@@ -161,16 +161,30 @@ var Base64 = {
return string;
}
-}
+};
+
+/*
+ * All collected fields in my LDIF file
+
+birthday, birthmonth, birthyear, c, cn, description, dn,
+facsimiletelephonenumber, givenName, homePhone, l, mail,
+mobile, modifytimestamp, mozillaHomeCountryName, mozillaHomeLocalityName,
+mozillaHomePostalCode, mozillaHomeState, mozillaHomeStreet,
+mozillaHomeUrl, mozillaNickname, mozillaSecondEmail,
+mozillaWorkStreet2, mozillaWorkUrl, o, objectclass, ou, postalCode,
+sn, st, street, telephoneNumber, title
+ */
+
// RFC 2849 uses givenname, RFC 4519 uses givenName, we rather support
// both
-const usefulFields = ["birthyear", "c", "cn", "description",
- "facsimiletelephonenumber", "givenName", "homePhone", "l", "mail",
- "mobile", "mozillaHomeCountryName", "mozillaHomeLocalityName",
+const usefulFields = ["birthyear", "birthmonth", "birthday", "c", "cn",
+ "description", "facsimiletelephonenumber", "givenName", "homePhone", "l",
+ "mail", "mobile", "mozillaHomeCountryName", "mozillaHomeLocalityName",
"mozillaHomePostalCode", "mozillaHomeState", "mozillaHomeStreet",
- "mozillaHomeUrl", "mozillaNickname", "o", "sn", "st", "street",
- "telephoneNumber", "title", "objectclass", "givenname"
+ "mozillaHomeUrl", "mozillaNickname", "mozillaSecondEmail",
+ "mozillaWorkStreet2", "mozillaWorkUrl", "o", "ou", "postalCode", "sn",
+ "st", "street", "telephoneNumber", "title", "objectclass", "givenname"
];
function debug(str) {
@@ -295,6 +309,11 @@ function parseLDIF(inStr) {
return out_records;
}
-if (exports !== undefined) {
+if (typeof(exports) !== "undefined") {
exports.parseLDIF = parseLDIF;
}
+
+if ((typeof(arguments) !== "undefined") && arguments.length == 1) {
+ var lines = readFile(arguments[0]).replace(/\r\n/g,"\n");
+ print(parseLDIF(lines.split("\n")).toSource());
+}