mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 11:55:20 +01:00
Never more
This commit is contained in:
@@ -247,8 +247,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
private static final ExecutorService precompute =
|
||||
Helper.getBackgroundExecutor(1, "precompute");
|
||||
|
||||
private static final int LARGE_MESSAGE_SIZE = 250 * 1024;
|
||||
|
||||
// https://github.com/newhouse/url-tracking-stripper
|
||||
private static final List<String> PARANOID_QUERY = Collections.unmodifiableList(Arrays.asList(
|
||||
// https://en.wikipedia.org/wiki/UTM_parameters
|
||||
@@ -1749,9 +1747,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
|
||||
return document.html();
|
||||
} else {
|
||||
if (body.length() > LARGE_MESSAGE_SIZE)
|
||||
return HtmlHelper.fromHtml("<em>" + context.getString(R.string.title_too_large) + "</em>");
|
||||
|
||||
// Cleanup message
|
||||
document = HtmlHelper.sanitize(context, body, show_images, true);
|
||||
|
||||
@@ -3495,6 +3490,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
} else {
|
||||
if ("more".equals(uri.getScheme())) {
|
||||
TupleMessageEx message = getMessage();
|
||||
if (message != null)
|
||||
onShow(message, true);
|
||||
return (message != null);
|
||||
}
|
||||
|
||||
if ("cid".equals(uri.getScheme()) || "data".equals(uri.getScheme()))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ public class HtmlHelper {
|
||||
private static final float MIN_LUMINANCE = 0.5f;
|
||||
private static final int TAB_SIZE = 2;
|
||||
private static final int MAX_AUTO_LINK = 250;
|
||||
private static final int MAX_TEXT_SIZE = 50 * 1024; // characters
|
||||
private static final int TRACKING_PIXEL_SURFACE = 25; // pixels
|
||||
|
||||
private static final List<String> heads = Collections.unmodifiableList(Arrays.asList(
|
||||
@@ -714,11 +715,28 @@ public class HtmlHelper {
|
||||
if (!TextUtils.isEmpty(span.attr("color")))
|
||||
span.tagName("font");
|
||||
|
||||
int length = 0;
|
||||
for (Element elm : document.select("*")) {
|
||||
for (Node child : elm.childNodes())
|
||||
if (child instanceof TextNode)
|
||||
length += ((TextNode) child).text().length();
|
||||
if (length > MAX_TEXT_SIZE)
|
||||
elm.remove();
|
||||
}
|
||||
|
||||
if (document.body() == null) {
|
||||
Log.e("Sanitize without body");
|
||||
document.normalise();
|
||||
}
|
||||
|
||||
if (length > MAX_TEXT_SIZE)
|
||||
document.body()
|
||||
.appendElement("p")
|
||||
.appendElement("big")
|
||||
.appendElement("a")
|
||||
.attr("href", "more:")
|
||||
.text(context.getString(R.string.title_show_more));
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user