From 5aaa26c484704a0c06a6075bb77970766d3a528e Mon Sep 17 00:00:00 2001 From: bleakgrey Date: Fri, 1 Jun 2018 16:03:37 +0300 Subject: [PATCH] Escape ampersands when sending toots --- src/Dialogs/PostDialog.vala | 5 ++--- src/Utils.vala | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Dialogs/PostDialog.vala b/src/Dialogs/PostDialog.vala index 7059683..1ac2844 100644 --- a/src/Dialogs/PostDialog.vala +++ b/src/Dialogs/PostDialog.vala @@ -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); diff --git a/src/Utils.vala b/src/Utils.vala index 7c24d77..4c24d4d 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -31,6 +31,11 @@ public class Tootle.Utils{ .replace ("&", "&") .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 ();