Always strip unsupported HTML in RichLabel
This commit is contained in:
parent
ffbc9f7736
commit
2726886130
|
@ -5,20 +5,20 @@ public class Tootle.Html {
|
|||
return all_tags.replace(content, -1, 0, "");
|
||||
}
|
||||
|
||||
public static string simplify (string content) {
|
||||
public static string simplify (string content) {
|
||||
var divided = content
|
||||
.replace("<br>", "\n")
|
||||
.replace("</br>", "")
|
||||
.replace("<br />", "\n")
|
||||
.replace("<p>", "")
|
||||
.replace("</p>", "\n\n");
|
||||
|
||||
|
||||
var html_params = new Regex("(class|target|rel)=\"(.|\n)*?\"", RegexCompileFlags.CASELESS);
|
||||
var simplified = html_params.replace(divided, -1, 0, "");
|
||||
|
||||
|
||||
while (simplified.has_suffix ("\n"))
|
||||
simplified = simplified.slice (0, simplified.last_index_of ("\n"));
|
||||
|
||||
|
||||
return simplified;
|
||||
}
|
||||
|
||||
|
@ -26,5 +26,5 @@ public class Tootle.Html {
|
|||
var to_escape = ";&+";
|
||||
return Soup.URI.encode (content, to_escape);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class Tootle.AccountView : TimelineView {
|
|||
public void rebind (){
|
||||
display_name.set_label ("<b>%s</b>".printf (account.display_name));
|
||||
username.label = "@" + account.acct;
|
||||
note.set_label (Html.simplify (account.note));
|
||||
note.set_label (account.note);
|
||||
button_follow.visible = !account.is_self ();
|
||||
network.load_avatar (account.avatar, avatar, 128);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class Tootle.RichLabel : Gtk.Label {
|
|||
}
|
||||
|
||||
public new void set_label (string text) {
|
||||
base.set_markup (escape_entities (text));
|
||||
base.set_markup (Html.simplify(escape_entities (text)));
|
||||
}
|
||||
|
||||
public void wrap_words () {
|
||||
|
|
|
@ -208,7 +208,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
|
||||
title_user.set_label ("<b>%s</b>".printf ((formal.account.display_name)));
|
||||
title_acct.label = "@" + formal.account.acct;
|
||||
content_label.label = formal.content;
|
||||
content_label.set_label (formal.content);
|
||||
content_label.mentions = formal.mentions;
|
||||
pin_indicator.visible = status.pinned;
|
||||
|
||||
|
|
Loading…
Reference in New Issue