pull/174/head
M66B 5 years ago
parent 81e97da66b
commit cf64335cb4

@ -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;
}

@ -694,7 +694,7 @@
<string name="title_no_format">The originally received message will be included</string>
<string name="title_no_image">Image could not be decoded</string>
<string name="title_no_search">Search on server is not available for this account</string>
<string name="title_too_large">Message too large to reformat, try to use the original message view via the full screen icon instead</string>
<string name="title_show_more">Show more &#8230;</string>
<string name="title_unused_inline">Unused inline images will be removed on send</string>
<string name="title_accross_remark">Messages moved across accounts will be downloaded again resulting in extra data usage</string>
<string name="title_raw_saved">Raw message saved</string>

Loading…
Cancel
Save