From: TSUCHIYA Masatoshi <tsuchiya@namazu.org>
To: ding@gnus.org
Subject: Re: Make ietf-drums-remove-comments() robust against broken header
Date: Fri, 31 Oct 2008 09:35:16 +0900 [thread overview]
Message-ID: <87abclmwjf.fsf@tsuchiya.vaj.namazu.org> (raw)
In-Reply-To: <b4mabclpsin.fsf@jpl.org> (Katsumi Yamaoka's message of "Fri, 31 Oct 2008 08:33:52 +0900")
>> 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
next prev parent reply other threads:[~2008-10-31 0:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-30 7:11 TSUCHIYA Masatoshi
2008-10-30 8:54 ` Katsumi Yamaoka
2008-10-30 9:07 ` Bjørn Mork
2008-10-30 9:25 ` Katsumi Yamaoka
2008-10-30 14:27 ` Bjørn Mork
2008-10-30 14:38 ` TSUCHIYA Masatoshi
2008-10-30 23:33 ` Katsumi Yamaoka
2008-10-31 0:35 ` TSUCHIYA Masatoshi [this message]
2008-10-31 1:21 ` Katsumi Yamaoka
2008-10-31 3:19 ` Ted Zlatanov
2008-10-31 7:26 ` Katsumi Yamaoka
2008-10-31 9:06 ` Katsumi Yamaoka
2008-10-31 17:34 ` Ted Zlatanov
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=87abclmwjf.fsf@tsuchiya.vaj.namazu.org \
--to=tsuchiya@namazu.org \
--cc=ding@gnus.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).