Commit 88f97930 authored by Ricki Hirner's avatar Ricki Hirner

NPE: search Content-Type only for charset when it's present

parent 80cd6f8a
......@@ -20,8 +20,8 @@ android {
applicationId "at.bitfire.icsdroid"
minSdkVersion 14
targetSdkVersion 22
versionCode 5
versionName "1.1"
versionCode 6
versionName "1.2-alpha1"
}
buildTypes {
release {
......
......@@ -170,14 +170,16 @@ public class SyncAdapter extends AbstractThreadedSyncAdapter {
// assume UTF-8 by default [RFC 5445 3.1.4]
Charset charset = Charsets.UTF_8;
Matcher m = regexContentTypeCharset.matcher(contentType);
if (m.find())
try {
charset = Charset.forName(m.group(1));
Log.v(TAG, "Using charset " + charset.displayName());
} catch(IllegalCharsetNameException|UnsupportedCharsetException e) {
Log.e(TAG, "Illegal or unsupported character set, assuming UTF-8", e);
}
if (contentType != null) {
Matcher m = regexContentTypeCharset.matcher(contentType);
if (m.find())
try {
charset = Charset.forName(m.group(1));
Log.v(TAG, "Using charset " + charset.displayName());
} catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
Log.e(TAG, "Illegal or unsupported character set, assuming UTF-8", e);
}
}
return charset;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment