Merge "ICS Writer: Quote common name."
This commit is contained in:
commit
90299163a3
@ -1392,7 +1392,7 @@ public class CalendarUtilities {
|
|||||||
if ((messageFlag & Message.FLAG_OUTGOING_MEETING_REQUEST_MASK) != 0) {
|
if ((messageFlag & Message.FLAG_OUTGOING_MEETING_REQUEST_MASK) != 0) {
|
||||||
String icalTag = ICALENDAR_ATTENDEE_INVITE;
|
String icalTag = ICALENDAR_ATTENDEE_INVITE;
|
||||||
if (attendeeName != null) {
|
if (attendeeName != null) {
|
||||||
icalTag += ";CN=" + attendeeName;
|
icalTag += ";CN=" + SimpleIcsWriter.quoteParamValue(attendeeName);
|
||||||
}
|
}
|
||||||
ics.writeTag(icalTag, "MAILTO:" + attendeeEmail);
|
ics.writeTag(icalTag, "MAILTO:" + attendeeEmail);
|
||||||
toList.add(attendeeName == null ? new Address(attendeeEmail) :
|
toList.add(attendeeName == null ? new Address(attendeeEmail) :
|
||||||
|
@ -69,4 +69,17 @@ public class SimpleIcsWriter extends CharArrayWriter {
|
|||||||
write(value);
|
write(value);
|
||||||
newLine();
|
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("\"", "") + "\"";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,13 @@ public class SimpleIcsWriterTests extends TestCase {
|
|||||||
assertEquals(SimpleIcsWriter.MAX_LINE_LENGTH + SimpleIcsWriter.LINE_BREAK_LENGTH +
|
assertEquals(SimpleIcsWriter.MAX_LINE_LENGTH + SimpleIcsWriter.LINE_BREAK_LENGTH +
|
||||||
(SimpleIcsWriter.MAX_LINE_LENGTH - 1), str.indexOf(expectedSecondLineBreak));
|
(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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user