From: Jani Nikula Date: Sat, 30 Nov 2013 15:33:50 +0000 (+0200) Subject: [PATCH v2 1/7] cli: sanitize tabs and newlines to spaces in notmuch search X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e33e521c7127108cfc000ca7ef6d48839560f901;p=notmuch-archives.git [PATCH v2 1/7] cli: sanitize tabs and newlines to spaces in notmuch search --- diff --git a/02/e13496e190d612cc8a8b50d70f504a39992ba5 b/02/e13496e190d612cc8a8b50d70f504a39992ba5 new file mode 100644 index 000000000..bad54deb1 --- /dev/null +++ b/02/e13496e190d612cc8a8b50d70f504a39992ba5 @@ -0,0 +1,113 @@ +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 BA7DF431FC9 + for ; Sat, 30 Nov 2013 07:34:09 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" +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 wNrJPPBKe5-B for ; + Sat, 30 Nov 2013 07:34:04 -0800 (PST) +Received: from mail-ea0-f170.google.com (mail-ea0-f170.google.com + [209.85.215.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 12D7A431FAF + for ; Sat, 30 Nov 2013 07:34:03 -0800 (PST) +Received: by mail-ea0-f170.google.com with SMTP id k10so7790543eaj.1 + for ; Sat, 30 Nov 2013 07:34:03 -0800 (PST) +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:in-reply-to:references; + bh=np75aVOqrb3NtR0M/v1YRcEvu6q3wIv4VSqv36hTOSA=; + b=ca/yn+mh3We85XXE09O+hz1piT4+YaA3eAqE1QNUsGN5iMTPc0dRGYb+j01s1wpyaz + Kp1JlXQ9o4VDdyaNdbREaddfZ4MY+HrPE5LmEtaxC4kWc7Nt4ZYNEU7DYcLB+IUlT2ja + vN0IjhfameuE44j0QqgymdZaY3/AIc/XRZVU3uXbTWwZEE5dRjt3lC4VlqSFFpR7O1RS + /Tyhl2GsckzHWN74+Qhn+yrDRUgQbOLkQjrxXwSYnKXy6RobRlEZp5bVUUzgntk+CzSS + XQB/gBcxp8Zy+W/rFtaI4NyMJHJ6qJS/S731n6jL98ay2Ivsj0Vr1WDkK5IEBHpfzMz/ + AFbg== +X-Gm-Message-State: + ALoCoQmcWE1KGEBRT55x5w8yTl9P0ym6bibLdK0T+QbIf7eXgVF9J9p2PB+U73B14ZMAvKmJz2Si +X-Received: by 10.14.179.130 with SMTP id h2mr25463113eem.34.1385825642995; + Sat, 30 Nov 2013 07:34:02 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) + by mx.google.com with ESMTPSA id m1sm46163441eeg.0.2013.11.30.07.34.01 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 30 Nov 2013 07:34:02 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH v2 1/7] cli: sanitize tabs and newlines to spaces in notmuch + search +Date: Sat, 30 Nov 2013 17:33:50 +0200 +Message-Id: + +X-Mailer: git-send-email 1.8.4.2 +In-Reply-To: +References: +In-Reply-To: +References: +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: Sat, 30 Nov 2013 15:34:09 -0000 + +Sanitize tabs and newlines to spaces rather than question marks in +--output=summary --format=text output. + +This will also hide any difference in unfolding a header that has been +folded with a tab. Our own header parser replaces tabs with spaces, +while gmime would retain the tab. +--- + notmuch-search.c | 4 +++- + test/search-output | 2 +- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/notmuch-search.c b/notmuch-search.c +index 7c973b3..11cd6ee 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -41,7 +41,9 @@ sanitize_string (const void *ctx, const char *str) + loop = out = talloc_strdup (ctx, str); + + for (; *loop; loop++) { +- if ((unsigned char)(*loop) < 32) ++ if (*loop == '\t' || *loop == '\n') ++ *loop = ' '; ++ else if ((unsigned char)(*loop) < 32) + *loop = '?'; + } + return out; +diff --git a/test/search-output b/test/search-output +index 5ccfeaf..86544ac 100755 +--- a/test/search-output ++++ b/test/search-output +@@ -388,7 +388,7 @@ add_message "[subject]='two =?ISO-8859-1?Q?line=0A_subject?= + headers'" + notmuch search id:"$gen_msg_id" | notmuch_search_sanitize >OUTPUT + cat <EXPECTED +-thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; two line? subject headers (inbox unread) ++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; two line subject headers (inbox unread) + EOF + test_expect_equal_file OUTPUT EXPECTED + +-- +1.8.4.2 +