mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 09:17:58 +00:00
Assume ISO-8859-1 if text/plain without charset
ICU4J is too large
This commit is contained in:
parent
2ac54627a0
commit
2709a66e34
4 changed files with 11 additions and 16 deletions
|
@ -137,7 +137,7 @@ FairEmail uses:
|
||||||
* [JavaMail](https://projects.eclipse.org/projects/ee4j.javamail). Copyright (c) 1997-2018 Oracle® and/or its affiliates. All rights reserved. [GPLv2+CE license](https://javaee.github.io/javamail/JavaMail-License).
|
* [JavaMail](https://projects.eclipse.org/projects/ee4j.javamail). Copyright (c) 1997-2018 Oracle® and/or its affiliates. All rights reserved. [GPLv2+CE license](https://javaee.github.io/javamail/JavaMail-License).
|
||||||
* [jsoup](https://jsoup.org/). Copyright © 2009 - 2017 Jonathan Hedley. [MIT license](https://jsoup.org/license).
|
* [jsoup](https://jsoup.org/). Copyright © 2009 - 2017 Jonathan Hedley. [MIT license](https://jsoup.org/license).
|
||||||
* ~~[JCharset](http://www.freeutils.net/source/jcharset/). Copyright © 2005-2015 Amichai Rothman. [GNU General Public License](http://www.freeutils.net/source/jcharset/#license)~~
|
* ~~[JCharset](http://www.freeutils.net/source/jcharset/). Copyright © 2005-2015 Amichai Rothman. [GNU General Public License](http://www.freeutils.net/source/jcharset/#license)~~
|
||||||
* [ICU4J](http://site.icu-project.org). Copyright © 1991-2019 Unicode, Inc. All rights reserved. [UNICODE, INC. LICENSE AGREEMENT](http://www.unicode.org/copyright.html#License)
|
* ~~[ICU4J](http://site.icu-project.org). Copyright © 1991-2019 Unicode, Inc. All rights reserved. [UNICODE, INC. LICENSE AGREEMENT](http://www.unicode.org/copyright.html#License)~~
|
||||||
* [Android Support Library](https://developer.android.com/tools/support-library/). Copyright (C) 2011 The Android Open Source Project. [Apache license](https://android.googlesource.com/platform/frameworks/support/+/master/LICENSE.txt).
|
* [Android Support Library](https://developer.android.com/tools/support-library/). Copyright (C) 2011 The Android Open Source Project. [Apache license](https://android.googlesource.com/platform/frameworks/support/+/master/LICENSE.txt).
|
||||||
* [Android Architecture Components](https://developer.android.com/topic/libraries/architecture/). Copyright 2018 The Android Open Source Project, Inc. [Apache license](https://github.com/googlesamples/android-architecture-components/blob/master/LICENSE).
|
* [Android Architecture Components](https://developer.android.com/topic/libraries/architecture/). Copyright 2018 The Android Open Source Project, Inc. [Apache license](https://github.com/googlesamples/android-architecture-components/blob/master/LICENSE).
|
||||||
* [colorpicker](https://android.googlesource.com/platform/frameworks/opt/colorpicker). Copyright (C) 2013 The Android Open Source Project. [Apache license](https://android.googlesource.com/platform/frameworks/opt/colorpicker/+/master/src/com/android/colorpicker/ColorPickerDialog.java).
|
* [colorpicker](https://android.googlesource.com/platform/frameworks/opt/colorpicker). Copyright (C) 2013 The Android Open Source Project. [Apache license](https://android.googlesource.com/platform/frameworks/opt/colorpicker/+/master/src/com/android/colorpicker/ColorPickerDialog.java).
|
||||||
|
|
|
@ -162,7 +162,7 @@ dependencies {
|
||||||
//implementation "net.freeutils:jcharset:$jcharset_version"
|
//implementation "net.freeutils:jcharset:$jcharset_version"
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.ibm.icu/icu4j
|
// https://mvnrepository.com/artifact/com.ibm.icu/icu4j
|
||||||
implementation "com.ibm.icu:icu4j:$icu4j_version"
|
//implementation "com.ibm.icu:icu4j:$icu4j_version"
|
||||||
|
|
||||||
// http://www.xbill.org/dnsjava/
|
// http://www.xbill.org/dnsjava/
|
||||||
implementation "dnsjava:dnsjava:$dnsjava_version"
|
implementation "dnsjava:dnsjava:$dnsjava_version"
|
||||||
|
|
|
@ -23,9 +23,6 @@ import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
import com.ibm.icu.text.CharsetDetector;
|
|
||||||
import com.ibm.icu.text.CharsetMatch;
|
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
|
||||||
|
@ -568,16 +565,15 @@ public class MessageHelper {
|
||||||
ContentType ct = new ContentType(part.getContentType());
|
ContentType ct = new ContentType(part.getContentType());
|
||||||
String charset = ct.getParameter("charset");
|
String charset = ct.getParameter("charset");
|
||||||
if (TextUtils.isEmpty(charset)) {
|
if (TextUtils.isEmpty(charset)) {
|
||||||
try {
|
if (BuildConfig.DEBUG)
|
||||||
CharsetDetector detector = new CharsetDetector();
|
warnings.add(context.getString(R.string.title_no_charset, ct.toString()));
|
||||||
String defset = (part.isMimeType("text/plain") ? "US-ASCII" : "ISO-8859-1");
|
if (part.isMimeType("text/plain"))
|
||||||
detector.setText(result.getBytes(defset));
|
try {
|
||||||
CharsetMatch match = detector.detect();
|
// The first 127 characters are the same as in US-ASCII
|
||||||
result = new String(result.getBytes(match.getName()));
|
result = new String(result.getBytes("ISO-8859-1"));
|
||||||
warnings.add(context.getString(R.string.title_guessed_charset, match.getName()));
|
} catch (UnsupportedEncodingException ex) {
|
||||||
} catch (UnsupportedEncodingException ex) {
|
warnings.add(Helper.formatThrowable(ex));
|
||||||
warnings.add(Helper.formatThrowable(ex));
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ("US-ASCII".equals(Charset.forName(charset).name()) &&
|
if ("US-ASCII".equals(Charset.forName(charset).name()) &&
|
||||||
!"US-ASCII".equals(charset.toUpperCase()))
|
!"US-ASCII".equals(charset.toUpperCase()))
|
||||||
|
|
|
@ -457,7 +457,6 @@
|
||||||
<string name="title_no_adobe">Adobe Acrobat reader cannot open safely shared files, see the FAQ for more information</string>
|
<string name="title_no_adobe">Adobe Acrobat reader cannot open safely shared files, see the FAQ for more information</string>
|
||||||
<string name="title_no_body">No message text found</string>
|
<string name="title_no_body">No message text found</string>
|
||||||
<string name="title_no_charset">Unsupported encoding: %1$s</string>
|
<string name="title_no_charset">Unsupported encoding: %1$s</string>
|
||||||
<string name="title_guessed_charset">Guessed encoding: %1$s</string>
|
|
||||||
|
|
||||||
<string name="title_try">Try FairEmail, an open source, privacy friendly email app for Android</string>
|
<string name="title_try">Try FairEmail, an open source, privacy friendly email app for Android</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue