[polari/gnome-3-38] flatpak: Include tp-idle fixes



commit 3fe73e45911b4f84f5d18229926710f7c52f58bd
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Oct 9 18:14:54 2020 +0200

    flatpak: Include tp-idle fixes
    
    Michael managed to figure out why some users keep disappearing \o/
    
    https://gitlab.gnome.org/GNOME/polari/-/merge_requests/163

 flatpak/org.gnome.Polari.json       |  8 ++++
 flatpak/tp-idle-fix-warning.patch   | 34 ++++++++++++++++
 flatpak/tp-idle-long-messages.patch | 79 +++++++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
---
diff --git a/flatpak/org.gnome.Polari.json b/flatpak/org.gnome.Polari.json
index 6656655e..785253c0 100644
--- a/flatpak/org.gnome.Polari.json
+++ b/flatpak/org.gnome.Polari.json
@@ -103,6 +103,14 @@
                 {
                     "type": "patch",
                     "path": "tp-idle-python3.patch"
+                },
+                {
+                    "type": "patch",
+                    "path": "tp-idle-long-messages.patch"
+                },
+                {
+                    "type": "patch",
+                    "path": "tp-idle-fix-warning.patch"
                 }
             ],
             "cleanup": [
diff --git a/flatpak/tp-idle-fix-warning.patch b/flatpak/tp-idle-fix-warning.patch
new file mode 100644
index 00000000..c22dab7f
--- /dev/null
+++ b/flatpak/tp-idle-fix-warning.patch
@@ -0,0 +1,34 @@
+From 8f04d4db50f29420022f11a48b5ecf132058c2f3 Mon Sep 17 00:00:00 2001
+From: Guillaume Desmottes <guillaume desmottes collabora co uk>
+Date: Fri, 14 Feb 2014 12:12:54 +0100
+Subject: [PATCH] idle-connection: make sure to always reset
+ force_disconnect_id
+
+Recent GLib raises a critical when trying to remove an invalid source.
+---
+ src/idle-connection.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/idle-connection.c b/src/idle-connection.c
+index 6ab5fea..8614d52 100644
+--- a/src/idle-connection.c
++++ b/src/idle-connection.c
+@@ -585,6 +585,7 @@ static gboolean _finish_shutdown_idle_func(gpointer data) {
+       IdleConnectionPrivate *priv = self->priv;
+       if (priv->force_disconnect_id != 0) {
+               g_source_remove(priv->force_disconnect_id);
++              priv->force_disconnect_id = 0;
+       }
+ 
+       tp_base_connection_finish_shutdown(conn);
+@@ -600,6 +601,7 @@ _force_disconnect (gpointer data)
+ 
+       IDLE_DEBUG("gave up waiting, forcibly disconnecting");
+       idle_server_connection_force_disconnect(priv->conn);
++      priv->force_disconnect_id = 0;
+       return FALSE;
+ }
+ 
+-- 
+2.28.0
+
diff --git a/flatpak/tp-idle-long-messages.patch b/flatpak/tp-idle-long-messages.patch
new file mode 100644
index 00000000..7ec51297
--- /dev/null
+++ b/flatpak/tp-idle-long-messages.patch
@@ -0,0 +1,79 @@
+From 0be57b4f449ce9289734f630873391ef1831dd3c Mon Sep 17 00:00:00 2001
+From: Michael Catanzaro <mcatanzaro gnome org>
+Date: Thu, 24 Sep 2020 07:03:10 -0500
+Subject: [PATCH] Properly handle long IRC messages
+
+IRC messages are delimited by CRLF. When the string passed to
+idle_parser_receive() doesn't end in \r or \n, the remaining parts get
+stashed away to be used to form a message on the next call to
+idle_parser_receive(). But telepathy-idle improperly assumes that the
+next call to idle_parser_receive() will definitely contain \r or \n,
+i.e. it assumes that an IRC message cannot be split between three calls
+to idle_parser_receive(). That assumption is wrong.
+
+Fixes polari#147
+---
+ src/idle-parser.c | 26 +++++++++++++++++++++-----
+ 1 file changed, 21 insertions(+), 5 deletions(-)
+
+diff --git a/src/idle-parser.c b/src/idle-parser.c
+index 159e6cc..71ca8b1 100644
+--- a/src/idle-parser.c
++++ b/src/idle-parser.c
+@@ -151,6 +151,7 @@ struct _IdleParserPrivate {
+ 
+       /* continuation line buffer */
+       gchar split_buf[IRC_MSG_MAXLEN + 3];
++      guint split_buf_used;
+ 
+       /* message handlers */
+       GSList *handlers[IDLE_PARSER_LAST_MESSAGE_CODE];
+@@ -226,6 +227,13 @@ strnlen(const char *msg, size_t maxlen)
+ }
+ #endif
+ 
++static void clear_split_buf(IdleParser *parser) {
++      IdleParserPrivate *priv = IDLE_PARSER_GET_PRIVATE(parser);
++
++      memset(priv->split_buf, '\0', IRC_MSG_MAXLEN + 3);
++      priv->split_buf_used = 0;
++}
++
+ void idle_parser_receive(IdleParser *parser, const gchar *msg) {
+       IdleParserPrivate *priv = IDLE_PARSER_GET_PRIVATE(parser);
+       guint i;
+@@ -245,7 +253,7 @@ void idle_parser_receive(IdleParser *parser, const gchar *msg) {
+                               if ((lasti == 0) && (priv->split_buf[0] != '\0')) {
+                                       g_strlcpy(g_stpcpy(concat_buf, priv->split_buf), msg, i + 1);
+                                       tmp = concat_buf;
+-                                      memset(priv->split_buf, '\0', IRC_MSG_MAXLEN + 3);
++                                      clear_split_buf(parser);
+                               } else {
+                                       tmp = g_strndup(msg + lasti, i - lasti);
+                               }
+@@ -264,10 +272,18 @@ void idle_parser_receive(IdleParser *parser, const gchar *msg) {
+               }
+       }
+ 
+-      if (!line_ends)
+-              g_strlcpy(priv->split_buf, msg + lasti, (IRC_MSG_MAXLEN + 3) - lasti);
+-      else
+-              memset(priv->split_buf, '\0', IRC_MSG_MAXLEN + 3);
++      if (!line_ends) {
++              len = strlen(msg + lasti);
++              if (len > (IRC_MSG_MAXLEN + 3) - priv->split_buf_used - 1) {
++                      IDLE_DEBUG("Discarding content that exceeds maximum message length: \"%s\"", msg + 
lasti);
++                      clear_split_buf(parser);
++              } else {
++                      g_strlcpy(priv->split_buf + priv->split_buf_used, msg + lasti, (IRC_MSG_MAXLEN + 3) - 
priv->split_buf_used);
++                      priv->split_buf_used += len;
++              }
++      } else {
++              clear_split_buf(parser);
++      }
+ }
+ 
+ void idle_parser_add_handler(IdleParser *parser, IdleParserMessageCode code, IdleParserMessageHandler 
handler, gpointer user_data) {
+-- 
+2.28.0
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]