<commit_before>'use strict';
// An RFC 2822 email header parser
/* eslint no-control-regex: 0 */

const logger = require('./logger');
const utils  = require('haraka-utils');
let Iconv;
try { Iconv = require('iconv').Iconv }
catch (err) {
    logger.logdebug("No iconv available - install with 'npm install iconv'");
}

class Header {
    constructor (options) {
        this.headers = {};
        this.headers_decoded = {};
        this.header_list = [];
        this.options = options;
    }

    parse (lines) {
        const self = this;

        for (let i=0,l=lines.length; i < l; i++) {
            const line = lines[i];
            if (/^[ \t]/.test(line)) {
                // continuation
                this.header_list[this.header_list.length - 1] += line;
            }
            else {
                this.header_list.push(line);
            }
        }

        for (let i=0,l=this.header_list.length; i < l; i++) {
            const match = this.header_list[i].match(/^([^\s:]*):\s*([\s\S]*)$/);
            if (match) {
                const key = match[1].toLowerCase();
                const val = match[2];

                this._add_header(key, val, "push");
            }
            else {
                logger.logerror("Header did not look right: " + this.header_list[i]);
            }
        }

        // Now add decoded versions<commit_msg>Change log level in mailheader.js (#2299)<commit_after>'use strict';
// An RFC 2822 email header parser
/* eslint no-control-regex: 0 */

const logger = require('./logger');
const utils  = require('haraka-utils');
let Iconv;
try { Iconv = require('iconv').Iconv }
catch (err) {
    logger.logdebug("No iconv available - install with 'npm install iconv'");
}

class Header {
    constructor (options) {
        this.headers = {};
        this.headers_decoded = {};
        this.header_list = [];
        this.options = options;
    }

    parse (lines) {
        const self = this;

        for (let i=0,l=lines.length; i < l; i++) {
            const line = lines[i];
            if (/^[ \t]/.test(line)) {
                // continuation
                this.header_list[this.header_list.length - 1] += line;
            }
            else {
                this.header_list.push(line);
            }
        }

        for (let i=0,l=this.header_list.length; i < l; i++) {
            const match = this.header_list[i].match(/^([^\s:]*):\s*([\s\S]*)$/);
            if (match) {
                const key = match[1].toLowerCase();
                const val = match[2];

                this._add_header(key, val, "push");
            }
            else {
                logger.lognotice("Header did not look right: " + this.header_list[i]);
            }
        }

        // Now add decoded versions
{'fraction_non_alphanumeric': 0.15257286793810723, 'fraction_numerical': 0.008636200071968334, 'mean_word_length': 1.6450999048525214, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4958907', 'n_tokens_mistral': 869, 'n_tokens_neox': 822, 'n_words': 192}