procmail
[Top] [All Lists]

Counting Content-Length ?

1997-12-30 13:34:22
Jari's pm-tips.txt has the following recipe for counting the size of the
file in bytes.

:0 B        # use HB to measure both head and body
* 1^1 .
* 1^1 ^.*$
{ textsize = $= }

Trying to understand it:

The first line (.) counts each character in the body and assigns a score of
1 to each of them. So this counts all the bytes in the file.

Questions:

1. Why is the 2nd line needed at all?

2. If it is needed to count the new-lines, how is it working exactly? What
about a mail with only 1 line WITHOUT a ending newline? In this case, the
count of the characters in the line _is_ the content-length, right?

3. What about empty lines like "\n\n" ? The RE above wont match them,
right? It needs something like '^$' :-), eh?

4. Is the recipe 100% accurate that I can replace any existing
Content-length headers with this score (after using HB to measure both head
and body of course) and not have any MUA which relies completely on
Content-Length: honk at me?

5. WAIM? (What am I missing?)

Thanks,
Vikas

<Prev in Thread] Current Thread [Next in Thread>