URL Encoding Confusion

According to RFC 1738, Section 2.2, a URL is a series of octets. Octets which have no visible ASCII representation, plus other problematic chars, must be encoded as %HH. It doesn’t say anything about character sets.

In all modern browsers (including Mozilla, now that bug 44272 is fixed), JavaScript’s escape() function (which was originally designed for escaping strings into URLs) uses %HH for Unicode codepoints below 0x0100, but %uHHHH for codepoints above there. Apparently, this is what the ECMAScript spec says. Where did this strange %u encoding come from? The newer (but not supported by IE 5.0) encodeURIComponent() seems to do the right thing, always encoding each individual byte of the character’s representation in UTF-8 as %HH.

Form submission seems to encode in the character set of the page, as %HH. So encodeURIComponent() matches form submission if the document is in the UTF-8 character set. Otherwise, it doesn’t.

But if you give IE a mailto: URL, it’ll decode any %HH bytes as if they were ISO-8859-1 (I think). Perhaps it’s using the default charset of the platform. So you have to use escape() – you can’t use encodeURIComponent, otherwise it gets things like U-UMLAUT wrong.

Mozilla, on the other hand, assumes UTF-8. But this means you can’t escape() something into a mailto: if it’s got characters in it between 0x007F and 0x0100. escape() uses %HH (direct encoding of value), whereas Mozilla expects %HH%HH (2-byte UTF-8). You need to use encodeURIComponent. >sigh<

So why does escape() use %uXXXX? What is IE up to? Is there some definitive representation of Unicode characters in URLs, or is it just a contract between client and server? Does anyone know of a document which explains all of this, in words of less than one syllable?

Pond Scum

Just when you think spammers, scammers and virus writers can’t sink any lower…

The Mozilla newsgroups are getting a few posts which attempt to persuade you to run some dodgy .scr file using pathetic attempts at social engineering. There are usually several posts with the same file, using a different technique. This time round, the first try was “american idol cat fight topless”. So nothing much new there, then. But the second was “iraq murder video gi head cut off”.

What scares me most is that there are people out there who would double-click such an attachment. Whatever they get, serves them right.

Why the CPL?

Microsoft has now released two pieces of software on Sourceforge under the IBM Common Public License (CPL). To adapt Wilde, one might be regarded as carelessness, but two looks deliberate, so I had a look at the CPL to see what might cause Microsoft to choose it.

  • It includes a patent license, but the scope of the license is only for Contributions which remain part of that particular program. They probably like this because it means they can release implementations of patented ideas without effectively nullifying their patent. I’m vaguely surprised this was adjudged as Free or Open Source; perhaps some patent grant is better than no patent grant. Also, given previous behaviour, I suspect they had to include something like this before anyone would touch their code with a barge pole.
  • The patent grant from a Contributor is revoked if you sue that Contributor over infringement of any software patent. They probably like this because the more CPLed code gets used, the fewer people can easily sue Microsoft for patent infringement – even if Microsoft sue them for it.
  • It’s somewhat copyleft – “separate modules of software distributed… under their own license agreement” do not fall under its scope. Perhaps they saw this as a way of trying to leverage the “we get to use other people’s improvements” part of open source while still being able to incorporate the result into proprietary products. Somewhat like the LGPL and MPL, in fact.
  • It’s incompatible with the GPL. It’s fairly obvious why they like this. They can’t co-opt or make proprietary GPLed code, so they don’t like the GPL at all, and don’t want to increase the amount of code under its umbrella.

Comments on my analysis are very welcome. :-)

Why We Will Lose the Software Patents Battle

I’ve written letters to MEPs. I’ve participated in online protests. I might even have gone to Brussels to protest if I could spare the time off work. But we aren’t going to win this one.

What’s that? “Don’t give up!”, I hear you cry. “There’s still hope!”. Is there? We are up against some powerful and well-funded vested interests, and we are not going to prevail unless we can mobilise thousands of people to contact the right representatives and make their views known. And hence we come to my point.

The main site dedicated to fighting software patents in Europe, at the Federation for a Free Information Infrastructure, is a confusing, verbose mess. It displays all the worst hallmarks of “Wikonfusion” – lots of links to vaguely related topics and no structure. There is nothing which tells me simply and concisely what the current situation is, and who I should be writing to this week. Their list of stuff you can do runs to 11 items, and five pages.

Last time I wrote to my MEP, it took me over an hour to gather enough information about the problem to be sure of what I was writing. I almost gave up several times. How many people did? This time round, I know that we’re at a crunch point, but I can’t find out what I’m supposed to do about it!

I don’t want to attack the people who are obviously doing a lot of hard work to achieve a massively important and worthwhile aim. It just frustrates and pains me that their sharp edge is being blunted by poor communication.

Update: I’ve just noticed an email in my very full inbox which tells me to respond if I want to do something. I will reply, and see what happens.