From c05d9ecb45dc7e72fc9aabc05e7b53984de1a83d Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 19 Mar 2014 18:44:50 +0200 Subject: [PATCH] [PATCH] cli: sanitize the received header before scanning for replies --- 2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96 | 116 ++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96 diff --git a/2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96 b/2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96 new file mode 100644 index 000000000..157077ace --- /dev/null +++ b/2d/d36e1a9dd07e77f9fdc7b8738c7c1470261d96 @@ -0,0 +1,116 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 17171431FBF + for ; Wed, 19 Mar 2014 09:45:01 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id CaPaXe5veKzP for ; + Wed, 19 Mar 2014 09:44:57 -0700 (PDT) +Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com + [74.125.83.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 5569F431FAF for ; Wed, 19 Mar 2014 09:44:57 -0700 + (PDT) +Received: by mail-ee0-f52.google.com with SMTP id e49so6697150eek.25 + for ; Wed, 19 Mar 2014 09:44:54 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=ZYgk1N422FXITOqmN3nTfM0xuLEGfgXh8q/J5SJSxv8=; + b=W/DG0MUAtVNxLcj0s2Fa0A4wRCi2VwVTSzoWZPr/f9JhOGJfL+dr3vz/8gxSTnRLte + 7IrM+r48EupwFcGMrbCiQ3gnQKX6VyUpW9qa98Y7gfUZ0Dkc51PwSPLizncuTR/0duXZ + A+02lqsgDMqXb4GTCOeF/ITIloioaHaA+2BgUTrvJifk2nEd2O7I5l4TyJGWjdJqdMXs + ACPPF/AGnONtPxARgm7JSjf8+QT8aI93PGv3zI/hxPMjxz6KBe/hCyYKxofLD96De+Rd + DzV0UiS5RtPcG2eXYAMmz9jeD6H2INvTD9LmrSA4XhPJDtqx9if1pBo58rad7aLg4DL/ + LfkQ== +X-Gm-Message-State: + ALoCoQl0lvbhG9to0H2RP3NbxM3ROy0GZVh6VpJRKcz4lK3/873XDoJtugtPTjA/D6kfIYlNrh3f +X-Received: by 10.14.105.4 with SMTP id j4mr23533068eeg.41.1395247494668; + Wed, 19 Mar 2014 09:44:54 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) + by mx.google.com with ESMTPSA id n5sm5208328eex.14.2014.03.19.09.44.52 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Wed, 19 Mar 2014 09:44:53 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH] cli: sanitize the received header before scanning for replies +Date: Wed, 19 Mar 2014 18:44:50 +0200 +Message-Id: <1395247490-19892-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 1.9.0 +In-Reply-To: <20140203204611.GL4375@mit.edu> +References: <20140203204611.GL4375@mit.edu> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 19 Mar 2014 16:45:01 -0000 + +This makes the from guessing agnostic to header folding by spaces or +tabs. + +--- + +I haven't had the time to update the rest of the series, but get the +prep patch out of the way. +--- + notmuch-reply.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/notmuch-reply.c b/notmuch-reply.c +index 47993d223090..7c1c80959ed6 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -21,6 +21,7 @@ + */ + + #include "notmuch-client.h" ++#include "string-util.h" + #include "sprinter.h" + + static void +@@ -465,14 +466,21 @@ guess_from_in_received_headers (notmuch_config_t *config, + notmuch_message_t *message) + { + const char *received, *addr; ++ char *sanitized; + + received = notmuch_message_get_header (message, "received"); + if (! received) + return NULL; + +- addr = guess_from_in_received_for (config, received); ++ sanitized = sanitize_string (NULL, received); ++ if (! sanitized) ++ return NULL; ++ ++ addr = guess_from_in_received_for (config, sanitized); + if (! addr) +- addr = guess_from_in_received_by (config, received); ++ addr = guess_from_in_received_by (config, sanitized); ++ ++ talloc_free (sanitized); + + return addr; + } +-- +1.9.0 + -- 2.26.2