Re: Leading zeroes in 1*DIGIT productions

On 18.12.08 14:21, Julian Reschke wrote:
> Ahem, it *is* explicitly allowed by the grammar.

Yes; that doesn't mean that it doesn't look plausibly unintentional.

> And code that properly processes the value will need no special
> treatment of leading zeros, it just follows from the way decimal numbers
> work.

So actually, I do know of a server that had a problem specifically with leading zeros because it was using an API which would treat such numbers as octal, absent the use-base-10 hint I promptly added when I discovered the problem:

http://hg.mozilla.org/mozilla-central/file/87267825681b/netwerk/test/httpserver/httpd.js#l1520

I didn't bring it up initially because it's more a matter of the person who wrote that line not being familiar with how parseInt works in JavaScript than of a deficiency in the specification, but code which properly processes /most/ Content-Length values may not necessarily properly process /all/ such values, in particular numbers which have the format of octal numbers with leading zeroes.  I think explicitly noting leading zeroes in accompanying prose makes it more likely that care will be taken in processing such values.

Jeff

P.S. -- Yes, that's an HTTP/1.1 server written in JavaScript.  No, it's not RFC2616-compliant (yet?), but it does enough to be used in fairly extensive browser testing.

Received on Tuesday, 23 December 2008 02:37:33 UTC