From 2d775713eccd27ef4bcbf32480b4f69892cc3986 Mon Sep 17 00:00:00 2001 From: mguessan Date: Mon, 19 Jul 2010 09:56:49 +0000 Subject: [PATCH] Carddav: fix case insensitive param values git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1201 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ExchangeSession.java | 6 +++--- src/java/davmail/exchange/VCardReader.java | 8 ++++---- .../exchange/TestExchangeSessionContact.java | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 3b1365a0..a49e678d 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -2683,13 +2683,13 @@ public abstract class ExchangeSession { } else if ("NICKNAME".equals(property.getKey())) { properties.put("nickname", property.getValue()); } else if ("TEL".equals(property.getKey())) { - if (property.hasParam("TYPE", "cell") || property.hasParam("X-GROUP", "CELL")) { + if (property.hasParam("TYPE", "cell") || property.hasParam("X-GROUP", "cell")) { properties.put("mobile", property.getValue()); } - if (property.hasParam("TYPE", "work") || property.hasParam("X-GROUP", "WORK")) { + if (property.hasParam("TYPE", "work") || property.hasParam("X-GROUP", "work")) { properties.put("telephoneNumber", property.getValue()); } - if (property.hasParam("TYPE", "home") || property.hasParam("X-GROUP", "HOME")) { + if (property.hasParam("TYPE", "home") || property.hasParam("X-GROUP", "home")) { properties.put("homePhone", property.getValue()); } if (property.hasParam("TYPE", "fax")) { diff --git a/src/java/davmail/exchange/VCardReader.java b/src/java/davmail/exchange/VCardReader.java index 6588ee78..e9443d26 100644 --- a/src/java/davmail/exchange/VCardReader.java +++ b/src/java/davmail/exchange/VCardReader.java @@ -175,28 +175,28 @@ public class VCardReader extends ICSBufferedReader { startIndex = i + 1; } else if (currentChar == ':') { if (startIndex < i) { - paramValues.add(line.substring(startIndex, i)); + paramValues.add(line.substring(startIndex, i).toLowerCase()); } property.addParam(paramName, paramValues); state = State.VALUE; startIndex = i + 1; } else if (currentChar == ';') { if (startIndex < i) { - paramValues.add(line.substring(startIndex, i)); + paramValues.add(line.substring(startIndex, i).toLowerCase()); } property.addParam(paramName, paramValues); state = State.PARAM_NAME; startIndex = i + 1; } else if (currentChar == ',') { if (startIndex < i) { - paramValues.add(line.substring(startIndex, i)); + paramValues.add(line.substring(startIndex, i).toLowerCase()); } startIndex = i + 1; } } else if (state == State.QUOTED_PARAM_VALUE) { if (currentChar == '"') { state = State.PARAM_VALUE; - paramValues.add(line.substring(startIndex, i)); + paramValues.add(line.substring(startIndex, i).toLowerCase()); startIndex = i + 1; } } else if (state == State.VALUE) { diff --git a/src/test/davmail/exchange/TestExchangeSessionContact.java b/src/test/davmail/exchange/TestExchangeSessionContact.java index a6806df7..d8786f9b 100644 --- a/src/test/davmail/exchange/TestExchangeSessionContact.java +++ b/src/test/davmail/exchange/TestExchangeSessionContact.java @@ -274,7 +274,22 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase assertNull(contact.get("haspicture")); assertNull(session.getContactPhoto(contact)); + } + public void testUpperCaseParamName() throws IOException { + ExchangeSession.Contact contact = (ExchangeSession.Contact) session.getItem("testcontactfolder", itemName); + + VCardWriter vCardWriter = new VCardWriter(); + vCardWriter.startCard(); + vCardWriter.appendProperty("TEL;TYPE=CELL", "mobile"); + vCardWriter.endCard(); + + ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), contact.etag, null); + assertEquals(200, result.status); + + contact = (ExchangeSession.Contact) session.getItem("testcontactfolder", itemName); + + assertEquals("mobile", contact.get("mobile")); } }