Fixes from audit

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2249 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2014-03-10 22:17:40 +00:00
parent 0fc908b1e9
commit b75fb15483
2 changed files with 18 additions and 24 deletions

View File

@ -26,7 +26,6 @@ import davmail.http.DavGatewayHttpClientFacade;
import davmail.ui.tray.DavGatewayTray;
import davmail.util.IOUtil;
import davmail.util.StringUtil;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.util.URIUtil;
@ -524,7 +523,7 @@ public class DavExchangeSession extends ExchangeSession {
mainPageReader = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
//noinspection StatementWithEmptyBody
String line;
while ((line = mainPageReader.readLine()) != null && line.toLowerCase().indexOf(BASE_HREF) == -1) {
while ((line = mainPageReader.readLine()) != null && !line.toLowerCase().contains(BASE_HREF)) {
}
if (line != null) {
// Exchange 2003
@ -912,6 +911,7 @@ public class DavExchangeSession extends ExchangeSession {
} else if (field.isIntValue()) {
// check value
try {
//noinspection ResultOfMethodCallIgnored
Integer.parseInt(value);
buffer.append(value);
} catch (NumberFormatException e) {
@ -1097,9 +1097,9 @@ public class DavExchangeSession extends ExchangeSession {
}
}
// workaround for messages in Sent folder
if (messageHeaders.indexOf("From:") < 0) {
if (!messageHeaders.contains("From:")) {
String from = getItemProperty(permanentUrl, "from");
messageHeaders = "From: "+from+"\n"+messageHeaders;
messageHeaders = "From: "+from+ '\n' +messageHeaders;
}
result = new ByteArrayInputStream(messageHeaders.getBytes("UTF-8"));
}
@ -2098,6 +2098,7 @@ public class DavExchangeSession extends ExchangeSession {
ITEM_PROPERTIES.add("contentclass");
}
@Override
protected Set<String> getItemProperties() {
return ITEM_PROPERTIES;
}
@ -2871,7 +2872,7 @@ public class DavExchangeSession extends ExchangeSession {
return uri.getEscapedURI();
}
public String encodeAndFixUrl(String url) throws URIException {
protected String encodeAndFixUrl(String url) throws URIException {
String originalUrl = URIUtil.encodePath(url);
if (restoreHostName && originalUrl.startsWith("http")) {
String targetPath = new URI(originalUrl, true).getEscapedPath();

View File

@ -29,7 +29,6 @@ import davmail.exchange.VProperty;
import davmail.http.DavGatewayHttpClientFacade;
import davmail.util.IOUtil;
import davmail.util.StringUtil;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.GetMethod;
@ -149,11 +148,7 @@ public class EwsExchangeSession extends ExchangeSession {
*/
@Override
protected boolean isBasicAuthentication(HttpClient httpClient, String url) {
if (url.toLowerCase().endsWith("/ews/exchange.asmx")) {
return false;
} else {
return super.isBasicAuthentication(httpClient, url);
}
return !url.toLowerCase().endsWith("/ews/exchange.asmx") && super.isBasicAuthentication(httpClient, url);
}
@Override
@ -228,7 +223,7 @@ public class EwsExchangeSession extends ExchangeSession {
alias = getAliasFromLogin();
// try to get email address with ResolveNames
email = resolveEmailAddress(userName);
resolveEmailAddress(userName);
// failover, build from host name
if (email == null) {
email = getAliasFromLogin() + getEmailSuffixFromHostname();
@ -308,8 +303,7 @@ public class EwsExchangeSession extends ExchangeSession {
LOGGER.debug("Current user email is " + email + ", alias is " + alias + " on " + serverVersion);
}
public String resolveEmailAddress(String userName) {
String email = null;
protected void resolveEmailAddress(String userName) {
String searchValue = userName;
int index = searchValue.indexOf('\\');
if (index >= 0) {
@ -328,7 +322,6 @@ public class EwsExchangeSession extends ExchangeSession {
} catch (IOException e) {
// ignore
}
return email;
}
protected static class AutoDiscoverMethod extends PostMethod {
@ -367,8 +360,8 @@ public class EwsExchangeSession extends ExchangeSession {
String line;
// find ews url
while ((line = autodiscoverReader.readLine()) != null
&& (line.indexOf("<EwsUrl>") == -1)
&& (line.indexOf("</EwsUrl>") == -1)) {
&& (!line.contains("<EwsUrl>"))
&& (!line.contains("</EwsUrl>"))) {
}
if (line != null) {
ewsUrl = line.substring(line.indexOf("<EwsUrl>") + 8, line.indexOf("</EwsUrl>"));
@ -1287,7 +1280,7 @@ public class EwsExchangeSession extends ExchangeSession {
if ("photo".equals(entry.getKey())) {
updates.add(Field.createFieldUpdate("haspicture", "true"));
} else if (!entry.getKey().startsWith("email") && !entry.getKey().startsWith("smtpemail")
&& !entry.getKey().equals("fileas")) {
&& !"fileas".equals(entry.getKey())) {
updates.add(Field.createFieldUpdate(entry.getKey(), entry.getValue()));
}
}
@ -1727,11 +1720,10 @@ public class EwsExchangeSession extends ExchangeSession {
executeMethod(getItemMethod);
if ("Task".equals(type)) {
VObject vTimezone = getVTimezone();
VCalendar localVCalendar = new VCalendar();
VObject vTodo = new VObject();
vTodo.type = "VTODO";
localVCalendar.setTimezone(vTimezone);
localVCalendar.setTimezone(getVTimezone());
vTodo.setPropertyValue("LAST-MODIFIED", convertDateFromExchange(getItemMethod.getResponseItem().get(Field.get("lastmodified").getResponseName())));
vTodo.setPropertyValue("CREATED", convertDateFromExchange(getItemMethod.getResponseItem().get(Field.get("created").getResponseName())));
String calendarUid = getItemMethod.getResponseItem().get(Field.get("calendaruid").getResponseName());
@ -1934,6 +1926,7 @@ public class EwsExchangeSession extends ExchangeSession {
EVENT_REQUEST_PROPERTIES.add("urlcompname");
}
@Override
protected Set<String> getItemProperties() {
return ITEM_PROPERTIES;
}
@ -2005,7 +1998,7 @@ public class EwsExchangeSession extends ExchangeSession {
@Override
public ContactPhoto getContactPhoto(ExchangeSession.Contact contact) throws IOException {
ContactPhoto contactPhoto = null;
ContactPhoto contactPhoto;
GetItemMethod getItemMethod = new GetItemMethod(BaseShape.ID_ONLY, ((EwsExchangeSession.Contact) contact).itemId, false);
getItemMethod.addAdditionalProperty(Field.get("attachments"));
@ -2164,11 +2157,11 @@ public class EwsExchangeSession extends ExchangeSession {
// find email
//noinspection StatementWithEmptyBody
while ((line = optionsPageReader.readLine()) != null
&& (line.indexOf("tblTmZn") == -1)
&& (line.indexOf("selTmZn") == -1)) {
&& (!line.contains("tblTmZn"))
&& (!line.contains("selTmZn"))) {
}
if (line != null) {
if (line.indexOf("tblTmZn") >= 0) {
if (line.contains("tblTmZn")) {
int start = line.indexOf("oV=\"") + 4;
int end = line.indexOf('\"', start);
result = line.substring(start, end);