From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.52.188.165 with SMTP id gb5cs450551vdc; Mon, 2 May 2011 15:03:03 -0700 (PDT) Received: by 10.229.7.3 with SMTP id b3mr6557449qcb.194.1304373783096; Mon, 02 May 2011 15:03:03 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id u17si14578849qcp.128.2011.05.02.15.03.02; Mon, 02 May 2011 15:03:03 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id AEDD918583BF; Mon, 2 May 2011 18:03:02 -0400 (EDT) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by rubyforge.org (Postfix) with ESMTP id 9CD9918583A2 for ; Mon, 2 May 2011 18:02:47 -0400 (EDT) Received: by wyb33 with SMTP id 33so5660687wyb.23 for ; Mon, 02 May 2011 15:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:from:to:date:message-id:user-agent :content-transfer-encoding:mime-version:content-type; bh=xSiUyJXgbScAcQA9VZ8DPtJWuP4+pS9Euv4k5Db0DAI=; b=nM4NbuaXFfVwDHNnxWh3RBy5goGevFyVRjOm9gJAdeYQNj8YYr3ZuIrtsxsPAQb6dT hHRZmpbhSrGDdRVXGQfe9UoDE7jHNqeN2riv2RVbUJhMn0g1ZHgx85VzCogDzg5HEHP5 2F2Ayge7jnKHjM5sV2lzGAG4sbkQbOTULFdRg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:date:message-id:user-agent :content-transfer-encoding:mime-version:content-type; b=wrmZX1UJq5+GpQUtdmimRAshQLiB1tApOVS93wWCrdVlgg+sZPudPyfYqCe17YbzMm IqhpXR1ZnCpmZwKFcFRy+4/PKjhvTGt2eHQLWPHFxIdNepOR6DgJeFuZp+q35oLTOJr6 R7XBKD0s7WN36eBC8xmxV5o9zDnz8nBXgiFaU= Received: by 10.216.241.197 with SMTP id g47mr2847936wer.24.1304373767323; Mon, 02 May 2011 15:02:47 -0700 (PDT) Received: from localhost (cpc12-cmbg15-2-0-cust81.5-4.cable.virginmedia.com [86.30.247.82]) by mx.google.com with ESMTPS id c54sm2884742wer.30.2011.05.02.15.02.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 02 May 2011 15:02:46 -0700 (PDT) From: Hamish To: sup-devel Date: Mon, 02 May 2011 23:02:43 +0100 Message-Id: <1304373710-sup-1383@whisper> User-Agent: Sup/git Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-1304373763-673054-6770-9645-1-=" Subject: [sup-devel] [PATCH] Fix problem with time parsing X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org --=-1304373763-673054-6770-9645-1-= Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline If a message has a date with month first and day second, then if the day is greater than 12, heliotrope crashes. This patch catches the error, and tries again after swapping the day and month. --- lib/heliotrope/maildir-walker.rb | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/lib/heliotrope/maildir-walker.rb b/lib/heliotrope/maildir-walker.rb index db9b9d4..47cb08b 100644 --- a/lib/heliotrope/maildir-walker.rb +++ b/lib/heliotrope/maildir-walker.rb @@ -43,7 +43,19 @@ private while(l = f.gets) if l =~ /^Date:\s+(.+\S)\s*$/ date = $1 - pdate = Time.parse($1) + begin + pdate = Time.parse($1) + rescue ArgumentError + # flip the day and month around and try again + if date =~ %r|(\d\d?)([-./])(\d\d?)([-./])(\d{2,4})| + date = $3 + $2 + $1 + $4 + $5 + pdate = Time.parse(date) + else + puts "Error while parsing time in file #{fn}" + puts "Matched date text was #{date}" + pdate = Time.at 0 + end + end return pdate end end -- 1.7.4.1 --=-1304373763-673054-6770-9645-1-= Content-Disposition: attachment; filename="0001-Fix-problem-with-time-parsing.patch" Content-Type: application/octet-stream; name="0001-Fix-problem-with-time-parsing.patch" Content-Transfer-Encoding: base64 RnJvbSAwNzNmZWFkNjA2ZDQyNzA0NDVjNzRlOTU3MmE5MWU2N2MyNGI0YTdh IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBIYW1pc2ggRG93bmVy IDxkbWlzaGRAZ21haWwuY29tPgpEYXRlOiBNb24sIDIgTWF5IDIwMTEgMjI6 NTY6MTcgKzAxMDAKU3ViamVjdDogW1BBVENIXSBGaXggcHJvYmxlbSB3aXRo IHRpbWUgcGFyc2luZwoKSWYgYSBtZXNzYWdlIGhhcyBhIGRhdGUgd2l0aCBt b250aCBmaXJzdCBhbmQgZGF5IHNlY29uZCwgdGhlbiBpZiB0aGUKZGF5IGlz IGdyZWF0ZXIgdGhhbiAxMiwgaGVsaW90cm9wZSBjcmFzaGVzLiBUaGlzIHBh dGNoIGNhdGNoZXMgdGhlCmVycm9yLCBhbmQgdHJpZXMgYWdhaW4gYWZ0ZXIg c3dhcHBpbmcgdGhlIGRheSBhbmQgbW9udGguCi0tLQogbGliL2hlbGlvdHJv cGUvbWFpbGRpci13YWxrZXIucmIgfCAgIDE0ICsrKysrKysrKysrKystCiAx IGZpbGVzIGNoYW5nZWQsIDEzIGluc2VydGlvbnMoKyksIDEgZGVsZXRpb25z KC0pCgpkaWZmIC0tZ2l0IGEvbGliL2hlbGlvdHJvcGUvbWFpbGRpci13YWxr ZXIucmIgYi9saWIvaGVsaW90cm9wZS9tYWlsZGlyLXdhbGtlci5yYgppbmRl eCBkYjliOWQ0Li40N2NiMDhiIDEwMDY0NAotLS0gYS9saWIvaGVsaW90cm9w ZS9tYWlsZGlyLXdhbGtlci5yYgorKysgYi9saWIvaGVsaW90cm9wZS9tYWls ZGlyLXdhbGtlci5yYgpAQCAtNDMsNyArNDMsMTkgQEAgcHJpdmF0ZQogICAg ICAgd2hpbGUobCA9IGYuZ2V0cykKICAgICAgICAgaWYgbCA9fiAvXkRhdGU6 XHMrKC4rXFMpXHMqJC8KICAgICAgICAgICBkYXRlID0gJDEKLSAgICAgICAg ICBwZGF0ZSA9IFRpbWUucGFyc2UoJDEpCisgICAgICAgICAgYmVnaW4KKyAg ICAgICAgICAgIHBkYXRlID0gVGltZS5wYXJzZSgkMSkKKyAgICAgICAgICBy ZXNjdWUgQXJndW1lbnRFcnJvcgorICAgICAgICAgICAgIyBmbGlwIHRoZSBk YXkgYW5kIG1vbnRoIGFyb3VuZCBhbmQgdHJ5IGFnYWluCisgICAgICAgICAg ICBpZiBkYXRlID1+ICVyfChcZFxkPykoWy0uL10pKFxkXGQ/KShbLS4vXSko XGR7Miw0fSl8CisgICAgICAgICAgICAgIGRhdGUgPSAkMyArICQyICsgJDEg KyAkNCArICQ1CisgICAgICAgICAgICAgIHBkYXRlID0gVGltZS5wYXJzZShk YXRlKQorICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICBwdXRzICJF cnJvciB3aGlsZSBwYXJzaW5nIHRpbWUgaW4gZmlsZSAje2ZufSIKKyAgICAg ICAgICAgICAgcHV0cyAiTWF0Y2hlZCBkYXRlIHRleHQgd2FzICN7ZGF0ZX0i CisgICAgICAgICAgICAgIHBkYXRlID0gVGltZS5hdCAwCisgICAgICAgICAg ICBlbmQKKyAgICAgICAgICBlbmQKICAgICAgICAgICByZXR1cm4gcGRhdGUK ICAgICAgICAgZW5kCiAgICAgICBlbmQKLS0gCjEuNy40LjEKCg== --=-1304373763-673054-6770-9645-1-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel --=-1304373763-673054-6770-9645-1-=--