bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Bug in regexp matching in data readed in binary mode


From: ShengHuo ZHU
Subject: Re: Bug in regexp matching in data readed in binary mode
Date: Wed, 15 Jan 2003 13:00:47 -0500
User-agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.3.50 (i686-pc-linux-gnu)

Alex Ott <ott@jet.msk.su> writes:

[...]

> I got this error many times when i read my mail with gnus via
> pop3. Gnus read data from pop3 server in binary mode and some time
> this bug lead to loss my letters.
>
> to reproduce this i write test case (in attachment). To reproduce you
> need open test.el in emacs and eval it twice (i can't understand why
> it not worked in first pass). file emacs-test-mail.txt must be in one
> dir with test.el - it is my test mail letter. after eval you got two
> buffers -- *test-case* with results of command output, and
> *test-result* with results of regexp match (buggy). 
>
> This error arise only when exists small russian char 'r', and also
> exists char '.' in end of string. so "^\\.\r\r" will match full
> string. 

I can reproduce the bug, however I think the bug is probably related
to the decoding part of the read_process_output function, which I am
not familiar with.

I hope that the following code (based on Alex's code) may illustrate
the bug in a better way.  The first piece of code returns t, which is
obviously wrong. But if we insert a space and delete it, it returns
nil in the second piece.

(let ((coding-system-for-read 'binary)
      (coding-system-for-write 'binary)
      (buf (get-buffer-create "*test-case*"))
      process)
  (with-current-buffer buf
    (erase-buffer)
    (setq process (start-process "test" buf "echo" "-e" "\r\n\305.\r\n"))
    (accept-process-output process)
    (goto-char (point-min))
    (search-forward ".\r")
    (forward-char -2)
    (looking-at "^\\.\r")))


(let ((coding-system-for-read 'binary)
      (coding-system-for-write 'binary)
      (buf (get-buffer-create "*test-case*"))
      process)
  (with-current-buffer buf
    (erase-buffer)
    (setq process (start-process "test" buf "echo" "-e" "\r\n\305.\r\n"))
    (accept-process-output process)
    (goto-char (point-min))
    (search-forward ".\r")
    (forward-char -3)
    (insert " ")
    (delete-backward-char 1)
    (forward-char 1)
    (looking-at "^\\.\r")))

ShengHuo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]