New MT 3.16 dirify bug: works with utf-8 but not with UTF-8

Publié le :

There was a bug in the dirify function in Movable Type which didn't know how to convert URLs from content encoded in Unicode. It hit me when I moved this blog from ISO-8859-1 to UTF-8 last year. At that time I hacked the MT code to fix this bug in such a way that an upgrade with a bug fix would work without further ado. So I was surprised, after upgrading to MT3.16 which was supposed to fix this bug, to see it coming back!

A quick look at /lib/MT/ shows this code for the dirify function in MT 3.16:

sub dirify {
($MT::VERSION && MT->instance->{cfg}->PublishCharset eq 'utf-8')
? utf8_dirify(@_) : iso_dirify(@_);

So obviously the test is case-sensitive. My config file had this line:

PublishCharset UTF-8

Bummer! Changing it to lowercase fixed the problem:

PublishCharset utf-8

I've filed a bug report at Six Apart. IMO all charset tests should be case insensitive.

Update: it's fixed in MT 3.17.