mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-02 21:24:34 +00:00
Check for pasting raw HTML
This commit is contained in:
parent
778849fb98
commit
dc814cffb9
2 changed files with 16 additions and 3 deletions
|
@ -484,7 +484,14 @@ public class EditTextCompose extends FixedEditText {
|
|||
ClipData.Item item = cbm.getPrimaryClip().getItemAt(0);
|
||||
|
||||
final String html;
|
||||
String h = item.getHtmlText();
|
||||
String h = null;
|
||||
if (raw) {
|
||||
CharSequence text = item.getText();
|
||||
if (text != null && HtmlHelper.isHtml(text.toString()))
|
||||
h = text.toString();
|
||||
}
|
||||
if (h == null)
|
||||
h = item.getHtmlText();
|
||||
if (h == null) {
|
||||
CharSequence text = item.getText();
|
||||
if (text == null)
|
||||
|
@ -497,9 +504,9 @@ public class EditTextCompose extends FixedEditText {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
SpannableStringBuilder ssb = (raw)
|
||||
SpannableStringBuilder ssb = (raw
|
||||
? new SpannableStringBuilderEx(html)
|
||||
: getSpanned(context, html);
|
||||
: getSpanned(context, html));
|
||||
|
||||
EditTextCompose.this.post(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -3829,6 +3829,12 @@ public class HtmlHelper {
|
|||
.remove("x-keep-line");
|
||||
}
|
||||
|
||||
static boolean isHtml(String text) {
|
||||
Pattern p = Pattern.compile(".*\\<[^>]+>.*", Pattern.DOTALL);
|
||||
boolean isHtml = p.matcher(text).matches();
|
||||
return isHtml;
|
||||
}
|
||||
|
||||
static Spanned fromHtml(@NonNull String html, Context context) {
|
||||
Document document = JsoupEx.parse(html);
|
||||
return fromDocument(context, document, null, null);
|
||||
|
|
Loading…
Reference in a new issue