Simplification

This commit is contained in:
M66B 2019-09-23 18:56:15 +02:00
parent f5b727a3c1
commit 444e0ebef8
2 changed files with 12 additions and 9 deletions

View File

@ -32,9 +32,6 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import java.util.ArrayList;
import javax.mail.internet.AddressException;
@ -143,15 +140,20 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
if (intent.hasExtra(Intent.EXTRA_HTML_TEXT)) {
String html = intent.getStringExtra(Intent.EXTRA_HTML_TEXT);
if (html != null)
args.putString("body", Jsoup.clean(html, Whitelist.relaxed()));
if (!TextUtils.isEmpty(html))
args.putString("body", html);
} else if (intent.hasExtra(Intent.EXTRA_TEXT)) {
CharSequence body = intent.getCharSequenceExtra(Intent.EXTRA_TEXT);
if (body != null)
if (body instanceof Spanned)
args.putString("body", Jsoup.clean(HtmlHelper.toHtml((Spanned) body), Whitelist.relaxed()));
else
args.putString("body", body.toString()); // TODO: clean?
args.putString("body", HtmlHelper.toHtml((Spanned) body));
else {
String text = body.toString();
if (!TextUtils.isEmpty(text)) {
String html = "<span>" + text.replaceAll("\\r?\\n", "<br>") + "</span>";
args.putString("body", html);
}
}
}
if (intent.hasExtra(Intent.EXTRA_STREAM))

View File

@ -2070,7 +2070,8 @@ public class FragmentCompose extends FragmentBase {
data.draft.subject = args.getString("subject", "");
body = args.getString("body", "");
body = body.replaceAll("\\r?\\n", "<br>");
if (!TextUtils.isEmpty(body))
body = HtmlHelper.sanitize(context, body, false);
if (answer > 0) {
EntityAnswer a = db.answer().getAnswer(answer);