Le 19/11/2011 23:48, Richard J.M. Hill a écrit :
The fact that a limit was placed on the maximum line-length suggests to me one of two things; either the person who wrote believed that it was necessary, or they were re-using code from somewhere else, and neglected to remove that restriction.
They took the code from the 'file' program where it's used to say "with very long lines". There is the following comment in the source: // This code is taken from the "file" command, where it is licensed // in the "beer-ware license" :-) // Original author: joerg@FreeBSD.ORG
The limit (TEXT_MAXLINELEN 300) is commented by: /* Maximal length of a line we consider "reasonable". */
And if there's such a line, they consider the file isn't a text file. That's not "reasonable", I think. ;-)
to be necessary, maybe we should try to imagine why it is there. The first thing that pops into my head (and again, remember my ignorance in the ways of programming) is that they wanted to avoid the possibility of buffer overflows or race conditions.
I don't think so. If a line is longer than 301 bytes, conf->resultBuf = MIME_TEXT_PLAIN is not executed, that's all. The code I modified is really only used to define if the file is plain text or not.