Thread View: news.software.nntp
3 messages
3 total messages
Started by Andrew - Supernews
Sun, 28 Mar 2004 21:38
UTF-8 wildmats in INN
Author: Andrew - Supernews
Date: Sun, 28 Mar 2004 21:38
Date: Sun, 28 Mar 2004 21:38
21 lines
1761 bytes
1761 bytes
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.)
The reason it fails is because INN is trying to handle non-utf8 data in the
code for the "*" metacharacter by advancing by octets rather than characters.
My own wildmat code does not do this unless the character after the * is
itself non-utf8 (and not a metacharacter); this came up because I tried
running the INN tests against my code, and got some different results.
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.
--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services
Re: UTF-8 wildmats in INN
Author: Russ Allbery
Date: Sun, 28 Mar 2004 22:32
Date: Sun, 28 Mar 2004 22:32
34 lines
2441 bytes
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.
Re: UTF-8 wildmats in INN
Author: Russ Allbery
Date: Mon, 17 May 2004 07:24
Date: Mon, 17 May 2004 07:24
18 lines
2030 bytes
2030 bytes
Russ Allbery <rra@stanford.edu> writes:
> 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.
I've taken this approach and it appears to work correctly. The new code
has been committed to CVS.
--
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads