From befa974de8b74877b2f1ea97e672d3eb2067a6d9 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Mon, 15 Mar 2010 11:28:26 -0700 Subject: [PATCH] Fix utility that retrieves tokens from RRULEs * The utility wasn't handling commas properly, causing the referenced bug * Fixed the utility and updated the relevant test case Bug: 2515488 Change-Id: Id229e50fcaaed1a0142db301eedaaba9209bed13 --- src/com/android/exchange/utility/CalendarUtilities.java | 2 +- .../android/exchange/utility/CalendarUtilitiesTests.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/android/exchange/utility/CalendarUtilities.java b/src/com/android/exchange/utility/CalendarUtilities.java index 6c1f58e6d..2455722cd 100644 --- a/src/com/android/exchange/utility/CalendarUtilities.java +++ b/src/com/android/exchange/utility/CalendarUtilities.java @@ -917,7 +917,7 @@ public class CalendarUtilities { char c; do { c = rrule.charAt(end++); - if (!Character.isLetterOrDigit(c) || (end == len)) { + if ((c == ';') || (end == len)) { if (end == len) end++; return rrule.substring(start, end -1); } diff --git a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java index b766800ff..8120a63d5 100644 --- a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java +++ b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java @@ -17,8 +17,8 @@ package com.android.exchange.utility; import com.android.email.R; -import com.android.email.Utility; import com.android.email.TestUtils; +import com.android.email.Utility; import com.android.email.mail.Address; import com.android.email.provider.EmailContent.Account; import com.android.email.provider.EmailContent.Attachment; @@ -93,11 +93,11 @@ public class CalendarUtilitiesTests extends AndroidTestCase { } public void testGenerateEasDayOfWeek() { - String byDay = "TU;WE;SA"; + String byDay = "TU,WE,SA"; // TU = 4, WE = 8; SA = 64; assertEquals("76", CalendarUtilities.generateEasDayOfWeek(byDay)); // MO = 2, TU = 4; WE = 8; TH = 16; FR = 32 - byDay = "MO;TU;WE;TH;FR"; + byDay = "MO,TU,WE,TH,FR"; assertEquals("62", CalendarUtilities.generateEasDayOfWeek(byDay)); // SU = 1 byDay = "SU"; @@ -109,6 +109,7 @@ public class CalendarUtilitiesTests extends AndroidTestCase { assertEquals("DAILY", CalendarUtilities.tokenFromRrule(rrule, "FREQ=")); assertEquals("1", CalendarUtilities.tokenFromRrule(rrule, "INTERVAL=")); assertEquals("17", CalendarUtilities.tokenFromRrule(rrule, "BYMONTHDAY=")); + assertEquals("WE,TH,SA", CalendarUtilities.tokenFromRrule(rrule, "BYDAY=")); assertNull(CalendarUtilities.tokenFromRrule(rrule, "UNTIL=")); }