Escape ampersands when sending toots

This commit is contained in:
bleakgrey 2018-06-01 16:03:37 +03:00
parent 178f869dbc
commit 5aaa26c484
2 changed files with 7 additions and 3 deletions

View File

@ -174,15 +174,14 @@ public class Tootle.PostDialog : Gtk.Dialog {
}
public void publish_post () {
var to_escape = ";";
var pars = "?status=%s&visibility=%s".printf (Soup.URI.encode (text.buffer.text, to_escape), visibility_opt.to_string ());
var pars = "?status=%s&visibility=%s".printf (Utils.encode (text.buffer.text), visibility_opt.to_string ());
pars += attachments.get_uri_array ();
if (in_reply_to != null)
pars += "&in_reply_to_id=%s".printf (in_reply_to.id.to_string ());
if (spoiler.active) {
pars += "&sensitive=true";
pars += "&spoiler_text=" + Soup.URI.encode (spoiler_text.buffer.text, to_escape);
pars += "&spoiler_text=" + Utils.encode (spoiler_text.buffer.text);
}
var url = "%s/api/v1/statuses%s".printf (Tootle.accounts.formal.instance, pars);

View File

@ -32,6 +32,11 @@ public class Tootle.Utils{
.replace ("'", "'");
}
public static string encode (string content) {
var to_escape = ";&";
return Soup.URI.encode (content, to_escape);
}
public static void copy (string str) {
var display = Tootle.window.get_display ();
var clipboard = Gtk.Clipboard.get_for_display (display, Gdk.SELECTION_CLIPBOARD);