SA Bugzilla – Bug 19
NoMailAudit header names case sensitive
Last modified: 2002-02-15 02:18:27 UTC
had a false negative with: Content-type: text/html due to CTYPE_JUST_HTML not triggering. turns out that check_for_content_type_just_html() looks for Content-Type: (upper-case T). I worked around this by changing the end of the function to: if ($ctype =~ /^text\/html\b/) { return 1; } $ctype = $self->get ('Content-type'); if ($ctype =~ /^text\/html\b/) { return 1; } Perhaps self->get() should do case-insensitive matches on the header field name..
Aiiiiyeee. The way get() is implemented will make this hard, but you're right, the header matching needs to be case-insensitive. We ran into this same issue elsewhere when the subject header appeared as SUBJECT: instead of the usual Subject: I'll leave it at P3 since it's not critical but will hopefully get around to it at some point.
Ok, I resolved this and have checked in a version to CVS which should solve all header-capitalization problems. I modified two functions in NoMailAudit to accomplish this: 1. get_header() now returns an array of all the headers which case-insentively match, so get_header("content-type") will give you Content-Type, Content-type, CoNtEnT-TyPe, etc. 2. replace_header() now replaces the first header which case-insensitively matches the arg, to replace_header("subject",$text) will replace Subject: or subject: or SUBJECT:, etc, whichever occurs first in the message. I imagine if there are bugs in this code, they'll show up fast, cos it gets hit a lot.
*** Bug 35 has been marked as a duplicate of this bug. ***