mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-20 04:31:47 -05:00
Fix up text/plain message view to escape < and > and & when converting plain text to html for display
This commit is contained in:
parent
0ffe1621a2
commit
d185adfc27
@ -1068,6 +1068,15 @@ public class MessageView extends Activity
|
|||||||
} else {
|
} else {
|
||||||
Matcher m = Regex.WEB_URL_PATTERN.matcher(text);
|
Matcher m = Regex.WEB_URL_PATTERN.matcher(text);
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
/*
|
||||||
|
* Convert plain text to HTML by replacing
|
||||||
|
* \r?\n with <br> and adding a html/body wrapper as well as escaping & < >
|
||||||
|
*/
|
||||||
|
text = text.replaceAll("&", "&");
|
||||||
|
text = text.replaceAll("<", "<");
|
||||||
|
text = text.replaceAll(">", ">");
|
||||||
|
text = text.replaceAll("\r?\n", "<br>");
|
||||||
|
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
int start = m.start();
|
int start = m.start();
|
||||||
if (start == 0 || (start != 0 && text.charAt(start - 1) != '@')) {
|
if (start == 0 || (start != 0 && text.charAt(start - 1) != '@')) {
|
||||||
@ -1079,12 +1088,6 @@ public class MessageView extends Activity
|
|||||||
}
|
}
|
||||||
m.appendTail(sb);
|
m.appendTail(sb);
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert plain text to HTML by replacing
|
|
||||||
* \r?\n with <br> and adding a html/body wrapper.
|
|
||||||
*/
|
|
||||||
text = sb.toString().replaceAll("\r?\n", "<br>");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
text = "<html><body>" + text + "</body></html>";
|
text = "<html><body>" + text + "</body></html>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user