Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
Cc: mule-ja@m17n.org
Subject: Re: pop3.el broken
Date: Fri, 15 Mar 2002 22:18:39 +0900	[thread overview]
Message-ID: <yosuadtanf4g.fsf@jpl.org> (raw)
In-Reply-To: <m37koekde8.fsf@peorth.gweep.net>

[-- Attachment #1: Type: text/plain, Size: 1790 bytes --]

The problem that the return value of `md5' for a multibyte string
and a unibyte string differ under Emacs 21 is caused by Mule-UCS.
However, it is not a bug of Mule-UCS.  What we should do is to
improve pop3.el after all.  I will attach a new patch.

The built-in function `md5' will encode a given string if it is a
multibyte string.  The coding-system for encoding is decided by
the following way:

(symbol-value (car coding-category-list))

You can find those procedures in fns.c.

Mule-UCS will put the coding category `coding-category-utf-16-le'
in the forefront of `coding-category-list' by default.  The
default value of `coding-category-utf-16-le' is `utf-16-le'.  And
a string extracted from a multibyte buffer will be a multibyte
string even if it does not contain non-ascii characters.  Thus
the code

(md5 (concat pop3-timestamp pass))

and

(md5 (encode-coding-string (concat pop3-timestamp pass) 'utf-16-le))

are equivalent and a string will be altered to 16-bit characters
as follows:

(encode-coding-string "dingnusdingnus" 'utf-16-le)
 => "\377\376d^@i^@n^@g^@n^@u^@s^@d^@i^@n^@g^@n^@u^@s^@"

Even if Mule-UCS is not used, a string as the first argument of
`md5' is always encoded by some coding-system, but almost all
coding-systems will not alter an ascii text.  Exceptionally, it
is a very rare case but it is possible that if a person has set
the value of `coding-category-iso-7' with the coding-system
`iso-2022-jp-1978-irv' (which is known as "old JIS") and push
`coding-category-iso-7' into `coding-category-list', she or he
would not be able to use the apop authentication with pop3.el.
In my opinion that it should never be her or his fault.


2002-03-15  Katsumi Yamaoka  <yamaoka@jpl.org>

	* pop3.el (pop3-string-as-unibyte): New macro.
	(pop3-apop): Use it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pop3.el.diff --]
[-- Type: text/x-patch, Size: 1006 bytes --]

--- pop3.el~	2002-03-13 21:56:17.780672000 +0000
+++ pop3.el	2002-03-15 12:58:08.964942000 +0000
@@ -307,6 +307,13 @@
     (if (not (and response (string-match "+OK" response)))
 	(pop3-quit process))))
 
+(eval-when-compile
+  (defmacro pop3-string-as-unibyte (string)
+    "Return a unibyte string with the same individual bytes as STRING."
+    (if (fboundp 'string-as-unibyte)
+	(list 'string-as-unibyte string)
+      string)))
+
 (defun pop3-apop (process user)
   "Send alternate authentication information to the server."
   (let ((pass pop3-password))
@@ -314,7 +321,8 @@
 	(setq pass
 	      (pop3-read-passwd (format "Password for %s: " pop3-maildrop))))
     (if pass
-	(let ((hash (pop3-md5 (concat pop3-timestamp pass))))
+	(let ((hash (pop3-md5 (pop3-string-as-unibyte
+			       (concat pop3-timestamp pass)))))
 	  (pop3-send-command process (format "APOP %s %s" user hash))
 	  (let ((response (pop3-read-response process t)))
 	    (if (not (and response (string-match "+OK" response)))

  reply	other threads:[~2002-03-15 13:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-13 10:58 Pavel Janík
2002-03-13 15:50 ` Stainless Steel Rat
2002-03-13 16:20 ` Bill White
2002-03-13 16:31   ` Bill White
2002-03-13 17:46 ` Bill White
2002-03-13 17:53   ` Paul Jarc
2002-03-13 20:21     ` Karl Kleinpaste
2002-03-13 19:58 ` Simon Josefsson
2002-03-13 22:39   ` Katsumi Yamaoka
2002-03-14  4:52     ` Stainless Steel Rat
2002-03-14  7:01       ` Katsumi Yamaoka
2002-03-14  9:35       ` Simon Josefsson
2002-03-14 22:11         ` Stainless Steel Rat
2002-03-15 13:18           ` Katsumi Yamaoka [this message]
2002-03-15 18:03             ` Simon Josefsson
2002-03-16  4:03               ` Stainless Steel Rat
2002-03-16  9:59                 ` Simon Josefsson
2002-03-16 10:24                   ` Simon Josefsson
2002-03-16 15:19                     ` Stainless Steel Rat
2002-03-18 13:03                       ` Katsumi Yamaoka
2002-03-18 15:53                         ` Stainless Steel Rat
2002-03-18 17:12                           ` Simon Josefsson
2002-03-18 18:04                             ` Stainless Steel Rat
2002-03-18 17:30                         ` Simon Josefsson
2002-03-18 23:43                           ` Katsumi Yamaoka
2002-03-19  1:13                             ` Stainless Steel Rat
2002-03-19  9:54                             ` Simon Josefsson
2002-03-16  3:57             ` Stainless Steel Rat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yosuadtanf4g.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=mule-ja@m17n.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).