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
This commit is contained in:
parent
a3b7559404
commit
d673da2868
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user