Carddav: implement quoted param value support

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1143 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-06 23:31:55 +00:00
parent c5642d4b41
commit ec74b95229
1 changed files with 32 additions and 5 deletions

View File

@ -99,7 +99,7 @@ public class VCardReader extends ICSBufferedReader {
}
protected static enum State {
KEY, PARAM_NAME, PARAM_VALUE, VALUE, BACKSLASH
KEY, PARAM_NAME, PARAM_VALUE, QUOTED_PARAM_VALUE, VALUE, BACKSLASH
}
public Property readProperty() throws IOException {
@ -129,19 +129,46 @@ public class VCardReader extends ICSBufferedReader {
state = State.PARAM_VALUE;
paramValues = new HashSet<String>();
startIndex = i + 1;
} else if (currentChar == ';') {
// param with no value
paramName = line.substring(startIndex, i);
property.addParam(paramName, null);
state = State.PARAM_NAME;
startIndex = i + 1;
} else if (currentChar == ':') {
// param with no value
paramName = line.substring(startIndex, i);
property.addParam(paramName, null);
state = State.VALUE;
startIndex = i + 1;
}
} else if (state == State.PARAM_VALUE) {
if (currentChar == ':') {
paramValues.add(line.substring(startIndex, i));
if (currentChar == '"') {
state = State.QUOTED_PARAM_VALUE;
startIndex = i + 1;
} else if (currentChar == ':') {
if (startIndex < i) {
paramValues.add(line.substring(startIndex, i));
}
property.addParam(paramName, paramValues);
state = State.VALUE;
startIndex = i + 1;
} else if (currentChar == ';') {
paramValues.add(line.substring(startIndex, i));
if (startIndex < i) {
paramValues.add(line.substring(startIndex, i));
}
property.addParam(paramName, paramValues);
state = State.PARAM_NAME;
startIndex = i + 1;
} else if (currentChar == ',') {
if (startIndex < i) {
paramValues.add(line.substring(startIndex, i));
}
startIndex = i + 1;
}
} else if (state == State.QUOTED_PARAM_VALUE) {
if (currentChar == '"') {
state = State.PARAM_VALUE;
paramValues.add(line.substring(startIndex, i));
startIndex = i + 1;
}
@ -152,7 +179,7 @@ public class VCardReader extends ICSBufferedReader {
} else if (currentChar == '\\') {
state = State.BACKSLASH;
}
// BACKSLASH state
// BACKSLASH state
} else {
state = State.VALUE;
}