From: anonymous <sup-bugs@masanjin.net>
To: sup-devel@rubyforge.org
Subject: [sup-devel] [issue114] Better quoted-text / top-post stripping
Date: Wed, 04 Aug 2010 12:31:13 +0000 [thread overview]
Message-ID: <1280925073.15.0.143313290118.issue114@masanjin.net> (raw)
In-Reply-To: <1280925073.15.0.143313290118.issue114@masanjin.net>
[-- Attachment #1: Type: text/plain, Size: 881 bytes --]
New submission from anonymous:
Redwood::Message splits a message into chunks and hides quoted text from a
previous message.
Top-posted responses are supported with BLOCK_QUOTE_PATTERN. This patch i) adds
a new pattern to hide top-posted text from Microsoft Entourage, ii) adds a fix
for Mozilla-based mail users who top post and iii) adds a new array-based config
option "block_quote_patterns" for adding additional patterns to treat as marking
the top of a top-posted response.
----------
files: patch.better-top-post-stripping
messages: 261
nosy: anonymous
priority: feature request
ruby_version: 1.8.7
status: unread
sup_version: 0.11
title: Better quoted-text / top-post stripping
_________________________________________
Sup issue tracker <sup-bugs@masanjin.net>
<http://masanjin.net/sup-bugs/issue114>
_________________________________________
[-- Attachment #2: patch.better-top-post-stripping --]
[-- Type: application/octet-stream, Size: 1483 bytes --]
--- lib/sup/message.rb.orig 2010-08-04 12:05:44.000000000 +0100
+++ lib/sup/message.rb 2010-08-04 13:27:07.000000000 +0100
@@ -25,7 +25,26 @@
end
QUOTE_PATTERN = /^\s{0,4}[>|\}]/
- BLOCK_QUOTE_PATTERN = /^-----\s*Original Message\s*----+$/
+
+ BLOCK_QUOTE_PATTERNS =
+ [
+ # NB: these should preferably not be anchored to line endings ('$') due
+ # to line ending encodings ('=20').
+
+ # At least three dashes. Mozilla mail clients downcase the 'm' in
+ # message.
+ /^----+\s*Original (M|m)essage\s*----+/,
+
+ # Microsoft Entourage doesn't indent quoted text, but it can be spotted
+ # with this line:
+ # On 8/2/10 1:23 PM, "John Doe" <edward@facebook.com> wrote:
+ /^On \d+\/\d+\/\d+ .+ wrote:/,
+ ]
+
+ if ar = $config[:block_quote_patterns]
+ BLOCK_QUOTE_PATTERNS += ar.map{ |s| Regexp.new(s) }
+ end
+
SIG_PATTERN = /(^-- ?$)|(^\s*----------+\s*$)|(^\s*_________+\s*$)|(^\s*--~--~-)|(^\s*--\+\+\*\*==)/
MAX_SIG_DISTANCE = 15 # lines from the end
@@ -540,8 +559,13 @@
newstate = :quote
elsif line =~ SIG_PATTERN && (lines.length - i) < MAX_SIG_DISTANCE
newstate = :sig
- elsif line =~ BLOCK_QUOTE_PATTERN
- newstate = :block_quote
+ else
+ for pattern in BLOCK_QUOTE_PATTERNS
+ if line =~ pattern
+ newstate = :block_quote
+ break
+ end
+ end
end
if newstate
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel
next parent reply other threads:[~2010-08-04 12:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-04 12:31 anonymous [this message]
2010-08-04 14:22 ` Alvaro Herrera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1280925073.15.0.143313290118.issue114@masanjin.net \
--to=sup-bugs@masanjin.net \
--cc=sup-devel@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox