From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/67710 Path: news.gmane.org!not-for-mail From: TSUCHIYA Masatoshi Newsgroups: gmane.emacs.gnus.general Subject: Re: Make ietf-drums-remove-comments() robust against broken header Date: Fri, 31 Oct 2008 09:35:16 +0900 Message-ID: <87abclmwjf.fsf@tsuchiya.vaj.namazu.org> References: <87wsfqsgk7.fsf@tsuchiya.vaj.namazu.org> <87zlkm78nq.fsf@obelix.mork.no> <87prli5fb2.fsf@obelix.mork.no> <87iqra2lnt.fsf@tsuchiya.vaj.namazu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1225413361 7866 80.91.229.12 (31 Oct 2008 00:36:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Oct 2008 00:36:01 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M16161@lists.math.uh.edu Fri Oct 31 01:37:03 2008 connect(): Connection refused Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kvi0b-0000Ej-QG for ding-account@gmane.org; Fri, 31 Oct 2008 01:37:02 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Kvhz4-00085w-7A; Thu, 30 Oct 2008 19:35:26 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Kvhz3-00085n-2f for ding@lists.math.uh.edu; Thu, 30 Oct 2008 19:35:25 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1Kvhyy-0000BE-G4 for ding@lists.math.uh.edu; Thu, 30 Oct 2008 19:35:25 -0500 Original-Received: from vaj.namazu.org ([202.221.179.42]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1Kvhz6-0000k4-00 for ; Fri, 31 Oct 2008 01:35:28 +0100 Original-Received: from vaj.namazu.org (vaj.namazu.org [202.221.179.42]) by vaj.namazu.org (Postfix) with ESMTP id 362901BAFB for ; Fri, 31 Oct 2008 09:35:17 +0900 (JST) X-cite: xcite 1.53 Mail-Followup-To: ding@gnus.org In-Reply-To: (Katsumi Yamaoka's message of "Fri, 31 Oct 2008 08:33:52 +0900") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux) X-Spam-Score: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:67710 Archived-At: >> On Fri, 31 Oct 2008 08:33:52 +0900 >> yamaoka@jpl.org (Katsumi Yamaoka) said as follows: >> References: (") <200810150047.AA17342@mailhost.example.net> >> which AFAICS is allowed. >The patch makes the function remove not only the odd comment but >also things following it. You meant it has to behave like the >following, didn't you? >(ietf-drums-remove-comments "(\") <200810150047.AA17342@mailhost.example.net>") > => " <200810150047.AA17342@mailhost.example.net>" >Ok. It is below. Anyway I believe we need to fix the function >whatever the way, or we cannot view messages having such odd comments. >TSUCHIYA-san, WDYT? I checked http://www.ietf.org/rfc/rfc2822.txt, and noticed that double-quote is always allowed as texts of comments. FWS = ([*WSP CRLF] 1*WSP) / ; Folding white space obs-FWS ctext = NO-WS-CTL / ; Non white space controls %d33-39 / ; The rest of the US-ASCII %d42-91 / ; characters not including "(", %d93-126 ; ")", or "\" ccontent = ctext / quoted-pair / comment comment = "(" *([FWS] ccontent) [FWS] ")" CFWS = *([FWS] comment) (([FWS] comment) / FWS) Therefore, I think that your solution can be simplified as follows. (defun ietf-drums-remove-comments (string) "Remove comments from STRING." (with-temp-buffer (let (c) (ietf-drums-init string) (while (not (eobp)) (setq c (char-after)) (cond ((eq c ?\") (forward-sexp 1)) ((eq c ?\() (delete-region (point) (condition-case nil (with-syntax-table (copy-syntax-table ietf-drums-syntax-table) (modify-syntax-entry ?\" "w") (forward-sexp 1) (point)) (error (point-max))))) (t (forward-char 1)))) (buffer-string)))) -- TSUCHIYA Masatoshi