GNU bug report logs - #12051
24.1; rcirc-send-message doesn't take multibyte into account.

Previous Next

Package: emacs;

Reported by: Li Ian-Xue <b4283 <at> bephor.org>

Date: Thu, 26 Jul 2012 01:17:02 UTC

Severity: normal

Found in version 24.1

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Leo <sdl.web <at> gmail.com>
To: Li Ian-Xue <b4283 <at> bephor.org>
Cc: 12051 <at> debbugs.gnu.org
Subject: bug#12051: 24.1; rcirc-send-message doesn't take multibyte into account.
Date: Mon, 13 Aug 2012 09:53:42 +0800
[Message part 1 (text/plain, inline)]
On 2012-07-26 00:18 +0800, Li Ian-Xue wrote:
> I discovered recently that the irc client `rcirc', although has an
> max-message-length set, but it simply uses (length str) for detecting
> the output length, which is not desirable for multibyte users because
> usually our characters encode to more than one byte, and this causes an
> error that the client actually sends out more bytes than the standard
> has required (512 bytes to my understanding).

Could you test if the attached patch fixes this problem? Thanks.

[0001-Fix-bug-12051.patch (text/x-patch, inline)]
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index e34b7c79..19f54a8e 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -794,26 +794,34 @@ (defun rcirc-buffer-nick (&optional buffer)
 (defvar rcirc-max-message-length 420
   "Messages longer than this value will be split.")
 
+(defun rcirc-split-message (message)
+  (with-temp-buffer
+    (insert message)
+    (goto-char (point-min))
+    (let (result)
+      (while (not (eobp))
+	(goto-char (or (byte-to-position rcirc-max-message-length)
+		       (point-max)))
+	(while (and (not (bobp))
+		    (> (length
+			(encode-coding-region (point-min) (point)
+					      rcirc-encode-coding-system t))
+		       rcirc-max-message-length))
+	  (forward-char -1))
+	(push (delete-and-extract-region (point-min) (point)) result))
+      (nreverse result))))
+
 (defun rcirc-send-message (process target message &optional noticep silent)
   "Send TARGET associated with PROCESS a privmsg with text MESSAGE.
 If NOTICEP is non-nil, send a notice instead of privmsg.
 If SILENT is non-nil, do not print the message in any irc buffer."
   ;; max message length is 512 including CRLF
-  (let* ((response (if noticep "NOTICE" "PRIVMSG"))
-         (oversize (> (length message) rcirc-max-message-length))
-         (text (if oversize
-                   (substring message 0 rcirc-max-message-length)
-                 message))
-         (text (if (string= text "")
-                   " "
-                 text))
-         (more (if oversize
-                   (substring message rcirc-max-message-length))))
+  (let ((response (if noticep "NOTICE" "PRIVMSG")))
     (rcirc-get-buffer-create process target)
-    (rcirc-send-string process (concat response " " target " :" text))
-    (unless silent
-      (rcirc-print process (rcirc-nick process) response target text))
-    (when more (rcirc-send-message process target more noticep))))
+    (dolist (msg (rcirc-split-message message))
+      (rcirc-send-string process (concat response " " target " :" msg))
+      (unless silent
+	(rcirc-print process (rcirc-nick process) response target msg)))))
 
 (defvar rcirc-input-ring nil)
 (defvar rcirc-input-ring-index 0)
-- 
1.7.9.6 (Apple Git-31.1)


This bug report was last modified 12 years and 284 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.