Fixes #66, JS call seeping into a python extension. Unit test added to test fix. 0.1
authorJames Burke <jrburke@mozillamessaging.com>
Sun, 25 Oct 2009 16:37:33 -0700
changeset 1010 d6354a0a49824cbf22c391c856df23f85f1fe5c4
parent 1009 e07f7793ad1b4974d9d7692b9025aa3fdce865c3
child 1011 4100519301878aa45f0f0f701e6b280b2f5457c3
push id464
push userjrburke@gmail.com
push dateSun, 25 Oct 2009 23:37:37 +0000
Fixes #66, JS call seeping into a python extension. Unit test added to test fix.
couch_docs/wq/rd.ext.core.msg-body-to-quoted.py
server/python/raindrop/tests/corpora/hand-rolled/quoted-simple.rfc822.txt
server/python/raindrop/tests/ext/test_simple_email.py
--- a/couch_docs/wq/rd.ext.core.msg-body-to-quoted.py
+++ b/couch_docs/wq/rd.ext.core.msg-body-to-quoted.py
@@ -50,17 +50,17 @@ def handler(doc):
         })
 
         #Find the end block and write that out.
         matches = collapseRegExp.search(text, startIndex)
         if matches:
           position = matches.end()
         else:
           #No match, so quote must be to the end of the string.
-          position = text.length - 1
+          position = len(text)
 
         ret.append({
             "text": text[startIndex:position],
             "type": "quote"
         })
 
         #Increment position in the string.
         oldIndex = startIndex = position
new file mode 100644
--- /dev/null
+++ b/server/python/raindrop/tests/corpora/hand-rolled/quoted-simple.rfc822.txt
@@ -0,0 +1,41 @@
+Delivered-To: doesnotexist@gmail.com
+Received: by 10.100.152.11 with SMTP id z11cs102771and;
+        Wed, 13 May 2009 19:01:24 -0700 (PDT)
+Received: by 10.114.113.6 with SMTP id l6mr1469789wac.204.1242266475573;
+        Wed, 13 May 2009 19:01:15 -0700 (PDT)
+Return-Path: <wwwrun@example2.com>
+Received: from mail.example2.com (mail.example2.com [64.93.73.94])
+        by mx.google.com with ESMTP id v39si472145wah.31.2009.05.13.19.01.15;
+        Wed, 13 May 2009 19:01:15 -0700 (PDT)
+Received-SPF: neutral (google.com: 64.93.73.94 is neither permitted nor denied by best guess record for domain of wwwrun@example2.com) client-ip=64.93.73.94;
+Authentication-Results: mx.google.com; spf=neutral (google.com: 64.93.73.94 is neither permitted nor denied by best guess record for domain of wwwrun@example2.com) smtp.mail=wwwrun@example2.com
+Received: by mail.example2.com (Postfix)
+	id 41542159D13; Wed, 13 May 2009 22:01:32 -0400 (EDT)
+Delivered-To: doesnotexist@example.com
+Received: by mail.example2.com (Postfix, from userid 65534)
+	id 3CEBA159D0E; Wed, 13 May 2009 22:01:32 -0400 (EDT)
+X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on
+	mailer.example2.com
+X-Spam-Level: 
+X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00
+	autolearn=ham version=3.2.3
+Received: from example2.com (unknown [192.168.0.1])
+	by mail.example2.com (Postfix) with ESMTP id 2A824159D0E
+	for <doesnotexist@example.com>; Wed, 13 May 2009 22:01:30 -0400 (EDT)
+Received: by example2.com (Postfix, from userid 30)
+	id C33915681F2D; Wed, 13 May 2009 19:01:18 -0700 (PDT)
+To: doesnotexist2@example.com
+Subject: Category subscription update for noone : Announcements 2
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8; format=flowed
+Content-Transfer-Encoding: 8Bit
+X-Mailer: Drupal
+Errors-To: noreply@example2.com
+Sender: noreply@example2.com
+Reply-To: noreply@example2.com
+From: noreply@example3.com
+Message-Id: <20090514020118.C33915681F2D@example3.com>
+Date: Wed, 13 May 2009 19:01:18 -0700 (PDT)
+
+2009/10/7 Some Body <somebody@example.com>:
+> this URL should not be picked up: http://example.com/quoted ok?
\ No newline at end of file
--- a/server/python/raindrop/tests/ext/test_simple_email.py
+++ b/server/python/raindrop/tests/ext/test_simple_email.py
@@ -73,16 +73,35 @@ class TestSimpleCorpus(TestCaseWithCorpu
             # and the contact
             
             key = ["rd.core.content", "key-schema_id", [rd_key, "rd.identity.contacts"]]
             result = yield self.doc_model.open_view(key=key, reduce=False,
                                                     include_docs=True)
             self.failUnlessEqual(len(result['rows']), 1, addy)
 
     @defer.inlineCallbacks
+    # Test for ticket #66 fix.
+    def test_simple_quoted(self):
+        ndocs = yield self.load_corpus("hand-rolled", "quoted-simple")
+        self.failUnlessEqual(ndocs, 1) # failed to load any corpus docs???
+        _ = yield self.ensure_pipeline_complete()
+
+        # load the hyperlinks document and compare the results.
+        key = ["rd.core.content", "schema_id", "rd.msg.body.quoted"]
+        result = yield self.doc_model.open_view(key=key, reduce=False,
+                                                include_docs=True)
+        
+        # Make sure we got one result.
+        self.failUnlessEqual(len(result['rows']), 1)
+        
+        # Make sure the right hyperlinks were found
+        doc = result['rows'][0]['doc']
+        self.failUnlessEqual(2, len(doc['parts']))
+
+    @defer.inlineCallbacks
     def test_quoted_hyperlinks(self):
         ndocs = yield self.load_corpus("hand-rolled", "quoted-hyperlinks")
         self.failUnlessEqual(ndocs, 1) # failed to load any corpus docs???
         _ = yield self.ensure_pipeline_complete()
 
         # load the hyperlinks document and compare the results.
         key = ["rd.core.content", "schema_id", "rd.msg.body.quoted.hyperlinks"]
         result = yield self.doc_model.open_view(key=key, reduce=False,