Subject: [Ltru] Small and embarassing discovery of today

From: Stephane Bortzmeyer <[email-masked]>
Date: Mon, 8 Oct 2007 16:14:58 +0200

There have been many discussions here about the matching of language
tags by applications and wether an application asked about 'oc-prv'
will find texts tagged with 'prv' if 'prv' is an extlang of the
macro-language 'oc'.

Several opinions expressed here have assumed that all authors have
read the RFC before coding, that all applications are carefully
written and well tested.

This may be true of big and visible applications like major Web
browsers. But there are also a lof of small and hastily written
applications that are less important but more numerous. I just
discovered a bug into an application I wrote (so I cannot put the
blame on a co-worker). Written in Python, a test said:

language = string.lower(tree.attrib.get('{http://www.w3.org/XML/1998/namespace}lang'))
if language != 'fr': # Specific rules for French texts

And the application failed to detect a 'fr-CA' text.

[For the record, the correct form should have been:
if language[0:1] != 'fr':
]

The moral? We should IMHO, stick with very simple rules because most
applications will not implement the complicated ones, anyway.

A similar case in the IETF is IPv6. My experience with IPv6 deployment
is that, yes, big and visible applications like the Linux kernel have
a working IPv6 support. But most of the software ecosystem (firewalls
generators, log parsers, even Palm Pilot IP address calculators) still
do not.

_______________________________________________
Ltru mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/ltru

---

From: Stephane Bortzmeyer <[email-masked]>
Date: Mon, 8 Oct 2007 21:10:50 +0200

On Mon, Oct 08, 2007 at 04:14:58PM +0200,
 Stephane Bortzmeyer <[email-masked]> wrote 

> if language[0:1] != 'fr':

Ooops, as noted by Addison Phillips, this should be:

if language[0:2] != "fr-":

Otherwise, language tag 'frr' (northern frisian) would match :-( Shame
on me.

---

From: Martin Hosken <[email-masked]>
Date: Tue, 09 Oct 2007 09:32:04 +0700

Dear Stephane,

> if language[0:2] != "fr-":

Shouldn't that be?

if language != 'fr' and language[0:2] != 'fr-' :

since a tag can just be 'fr'.

It gets harder and harder and that's just a simple comparison.

And we can't even decide how to advise people to tag text in a language.
Guys if we don't know what hope do we have of teaching others?

Yours,
Martin Hosken

---

From: Stephane Bortzmeyer <[email-masked]>
Date: Tue, 9 Oct 2007 11:28:12 +0200

On Tue, Oct 09, 2007 at 09:32:04AM +0700,
 Martin Hosken <[email-masked]> wrote 

> if language != 'fr' and language[0:2] != 'fr-' :

Yes, I'll stop patching this program, I introduce one more bug each
time :-( 

> Guys if we don't know what hope do we have of teaching others?

I'm probably not the best programmer on this list, as everyone can see
:-( But that was precisely my point. Many programmers are even worse
than me and will make similar mistakes. 

The odds of complicated matching being properly implemented are low,
IMHO.