mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-06 03:08:02 -05:00
Carddav: encode comma and \n in values
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1180 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
2cab4c6ded
commit
c9d908316a
@ -58,14 +58,34 @@ public class VCardWriter extends ICSBufferedWriter {
|
||||
} else {
|
||||
valueBuffer.append(';');
|
||||
}
|
||||
if (value != null) {
|
||||
valueBuffer.append(value);
|
||||
}
|
||||
appendEncodedValue(valueBuffer, value);
|
||||
}
|
||||
writeLine(valueBuffer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode and append value to buffer
|
||||
*
|
||||
* @param buffer current buffer
|
||||
* @param value property value
|
||||
*/
|
||||
private void appendEncodedValue(StringBuilder buffer, String value) {
|
||||
if (value != null) {
|
||||
for (int i = 0; i < value.length();i++) {
|
||||
char c = value.charAt(i);
|
||||
if (c == ',') {
|
||||
buffer.append('\\');
|
||||
}
|
||||
if (c == '\n') {
|
||||
buffer.append("\\n");
|
||||
} else {
|
||||
buffer.append(value.charAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endCard() {
|
||||
writeLine("END:VCARD");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user