diff --git a/src/com/android/exchange/utility/CalendarUtilities.java b/src/com/android/exchange/utility/CalendarUtilities.java index db1a2b9f5..6c1f58e6d 100644 --- a/src/com/android/exchange/utility/CalendarUtilities.java +++ b/src/com/android/exchange/utility/CalendarUtilities.java @@ -1392,7 +1392,7 @@ public class CalendarUtilities { if ((messageFlag & Message.FLAG_OUTGOING_MEETING_REQUEST_MASK) != 0) { String icalTag = ICALENDAR_ATTENDEE_INVITE; if (attendeeName != null) { - icalTag += ";CN=" + attendeeName; + icalTag += ";CN=" + SimpleIcsWriter.quoteParamValue(attendeeName); } ics.writeTag(icalTag, "MAILTO:" + attendeeEmail); toList.add(attendeeName == null ? new Address(attendeeEmail) : diff --git a/src/com/android/exchange/utility/SimpleIcsWriter.java b/src/com/android/exchange/utility/SimpleIcsWriter.java index ceb95a74d..32f6b2a9e 100644 --- a/src/com/android/exchange/utility/SimpleIcsWriter.java +++ b/src/com/android/exchange/utility/SimpleIcsWriter.java @@ -69,4 +69,17 @@ public class SimpleIcsWriter extends CharArrayWriter { write(value); newLine(); } + + /** + * Quote a param-value string, according to RFC 5545, section 3.1 + */ + public static String quoteParamValue(String paramValue) { + if (paramValue == null) { + return null; + } + // Wrap with double quotes. You can't put double-quotes itself in it, so remove them first. + // We can be smarter -- e.g. we don't have to wrap an empty string with dquotes -- but + // we don't have to. + return "\"" + paramValue.replace("\"", "") + "\""; + } } diff --git a/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java b/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java index c57291eb4..2240d20f5 100644 --- a/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java +++ b/tests/src/com/android/exchange/utility/SimpleIcsWriterTests.java @@ -65,4 +65,13 @@ public class SimpleIcsWriterTests extends TestCase { assertEquals(SimpleIcsWriter.MAX_LINE_LENGTH + SimpleIcsWriter.LINE_BREAK_LENGTH + (SimpleIcsWriter.MAX_LINE_LENGTH - 1), str.indexOf(expectedSecondLineBreak)); } + + public void testQuoteParamValue() { + assertNull(SimpleIcsWriter.quoteParamValue(null)); + assertEquals("\"\"", SimpleIcsWriter.quoteParamValue("")); + assertEquals("\"a\"", SimpleIcsWriter.quoteParamValue("a")); + assertEquals("\"\"", SimpleIcsWriter.quoteParamValue("\"")); + assertEquals("\"abc\"", SimpleIcsWriter.quoteParamValue("abc")); + assertEquals("\"abc\"", SimpleIcsWriter.quoteParamValue("a\"b\"c")); + } }