From d673da2868f55f910481e9768bea596db7879816 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 19 Mar 2010 18:41:33 -0700 Subject: [PATCH] Don't send null/empty values in SimpleIcsWriter * Previously, we would send "0", which is just wrong. Better to send nothing * Make sure that all tests pass Bug: 2531679 Change-Id: I01412c6c6f7a2570fafadede75671012b917d25b --- .../exchange/utility/SimpleIcsWriter.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/com/android/exchange/utility/SimpleIcsWriter.java b/src/com/android/exchange/utility/SimpleIcsWriter.java index 1f0dadfa1..8f46263c2 100644 --- a/src/com/android/exchange/utility/SimpleIcsWriter.java +++ b/src/com/android/exchange/utility/SimpleIcsWriter.java @@ -21,6 +21,7 @@ import android.text.TextUtils; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.UnsupportedEncodingException; /** * Class to generate iCalender object (*.ics) per RFC 5545. @@ -61,9 +62,9 @@ public class SimpleIcsWriter { * Write a tag with a value. */ public void writeTag(String name, String value) { - // Belt and suspenders here; don't crash on null value. Use something innocuous + // Belt and suspenders here; don't crash on null value; just return if (TextUtils.isEmpty(value)) { - value = "0"; + return; } // The following properties take a TEXT value, which need to be escaped. @@ -98,6 +99,18 @@ public class SimpleIcsWriter { writeLine(name + ":" + value); } + /** + * For debugging + */ + @Override + public String toString() { + try { + return new String(getBytes(), "UTF-8"); + } catch (UnsupportedEncodingException wonthappen) { + } + return null; + } + /** * @return the entire iCalendar invitation object. */