Carddav: fix line folding in generated VCARD

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1246 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-21 15:38:44 +00:00
parent 10db0a079a
commit 3a9c3daae4
1 changed files with 12 additions and 12 deletions

View File

@ -29,15 +29,16 @@ public class VCardWriter extends ICSBufferedWriter {
public void appendProperty(String propertyName, String propertyValue) {
if ((propertyValue != null) && (propertyValue.length() > 0)) {
write(propertyName);
write(":");
writeLine(encodeMultiline(propertyValue));
StringBuilder buffer = new StringBuilder();
buffer.append(propertyName);
buffer.append(':');
appendMultilineEncodedValue(buffer, propertyValue);
writeLine(buffer.toString());
}
}
protected String encodeMultiline(String value) {
StringBuilder buffer = new StringBuilder();
protected void appendMultilineEncodedValue(StringBuilder buffer, String value) {
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (c == '\n') {
@ -46,7 +47,6 @@ public class VCardWriter extends ICSBufferedWriter {
buffer.append(value.charAt(i));
}
}
return buffer.toString();
}
public void appendProperty(String propertyName, String... propertyValue) {
@ -58,19 +58,19 @@ public class VCardWriter extends ICSBufferedWriter {
}
}
if (hasValue) {
write(propertyName);
write(":");
boolean first = true;
StringBuilder valueBuffer = new StringBuilder();
StringBuilder buffer = new StringBuilder();
buffer.append(propertyName);
buffer.append(':');
for (String value : propertyValue) {
if (first) {
first = false;
} else {
valueBuffer.append(';');
buffer.append(';');
}
appendEncodedValue(valueBuffer, value);
appendEncodedValue(buffer, value);
}
writeLine(valueBuffer.toString());
writeLine(buffer.toString());
}
}