🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #68828

Re: UTF-8 wildmats in INN

#68828
From: Russ Allbery
Date: Sun, 28 Mar 2004 22:32
34 lines
2441 bytes
Andrew <- Supernews <andrew+nonews@supernews.com>> writes:

> If I add this to tests/lib/uwildmat-t.c (updating the test count), then
> it fails. I think this is an error. Comments?

>     test_r(167, "\303\206",       "*[^\303\206]",      false);

> (\303\206 is a valid utf-8 sequence, corresponding to U+00C6.)

I think you're right that this is a bug.

> My code currently sees "\303\206" as not matching "*[\206]" (but
> matching "*\206"), which is slightly strange, but I prefer to break the
> non-utf8 cases rather than the utf8 ones. I see no clean solution for
> this other than significantly restructuring the code.

The alternate approach that may not require a lot of code restructuring
that comes to mind for me is modifying * to skip complete UTF-8 characters
iff the octet sequence is a valid UTF-8 character, otherwise skipping
octets.  In other words, modify * so that it will only match all of
\303\206 or none of it, but will never match \303 in isolation provided
that the octets to make a complete UTF-8 character are available following
it in the string.

All the possible solutions to this break some non-UTF-8 in weird edge
cases, but the above seems to me like it would generally do the right
thing.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Technical Details
Message-ID: <87n060y54c.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
References: <slrnc6ehe7.25bv.andrew+nonews@trinity.supernews.net>

Show Full Headers
Complete Article Headers
Message-ID: <87n060y54c.fsf@windlord.stanford.edu>
Subject: Re: UTF-8 wildmats in INN
Date: Sun, 28 Mar 2004 14:32:51 -0800
From: Russ Allbery <rra@stanford.edu>
References: <slrnc6ehe7.25bv.andrew+nonews@trinity.supernews.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
Newsgroups: news.software.nntp
Organization: The Eyrie
Lines: 33
NNTP-Posting-Host: windlord.stanford.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.Stanford.EDU 1080513171 5879 171.64.19.147 (28 Mar 2004 22:32:51 GMT)
X-Complaints-To: news@news.stanford.edu
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Common Lisp, linux)
Cancel-Lock: sha1:UxggtOH9g31Yq0uiRWrBP4Ob+Tw=