[M-git] Mahogany sources repository. branch master updated. v0.67-627-geeaec08

"Vadim Zeitlin" <[email protected]> Thu, 8 Mar 2012 00:30:00 +0000
Newsgroups gmane.mail.mahogany.cvs
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Mahogany sources repository.".

The branch, master has been updated
       via  eeaec08a9f95ab41e8a58ca059da5b599a5dffbb (commit)
       via  e10ff8926a9ffc31acd774e8bce7fa2b27aeaeef (commit)
       via  723dcb7f321e9358445e53c1856afb2668827547 (commit)
      from  83b36c04deec25d15251a54edd54a373cdd31141 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit eeaec08a9f95ab41e8a58ca059da5b599a5dffbb
Author: Vadim Zeitlin <[email protected]>
Date:   Thu Mar 8 01:28:16 2012 +0100

    Fix crash when processing malformed inline-PGP-signed messages.
    
    Verify that we don't go beyond the end of the message while searching for the
    PGP signature. We actually didn't dereference any pointers to the memory
    beyond the end of the message but we tried to construct a string with begin
    position being greater than the end one in this case which used a negative
    (i.e. huge positive when converted to unsigned) length and crashed.

diff --git a/src/modules/viewflt/PGP.cpp b/src/modules/viewflt/PGP.cpp
index 9b83b77..47f50fb 100644
--- a/src/modules/viewflt/PGP.cpp
+++ b/src/modules/viewflt/PGP.cpp
@@ -306,7 +306,7 @@ PGPFilter::DoProcess(String& text,
                // beginNext points to the end of BEGIN line, go forward to the
                // end of the headers (signalled by an empty line i.e. 2 EOLs)
                beginNext = wxStrstr(beginNext, _T("\r\n\r\n"));
-               if ( beginNext )
+               if ( beginNext && beginNext < endNext )
                {
                   // endNext currently points to the end of END PGP SIGNATURE
                   // line, rewind to the PGP_BEGIN_SIG line
@@ -347,6 +347,11 @@ PGPFilter::DoProcess(String& text,
                                   _T("line doesn't end in\"\\r\\n\"?") );
                   }
                }
+               else
+               {
+                  wxLogWarning(_("Blank line separating header "
+                                 "from body in PGP message not found."));
+               }
             }
          }
          else // encrypted

commit e10ff8926a9ffc31acd774e8bce7fa2b27aeaeef
Author: Vadim Zeitlin <[email protected]>
Date:   Thu Mar 8 01:27:26 2012 +0100

    Fix compilation in release build under Windows.
    
    mail/FolderPool.h now is needed by the code handling power events too and not
    only for debug checks. Instead of using a complicated test for its inclusion,
    just include it always, avoiding it is not worth the complexity.

diff --git a/src/gui/wxMainFrame.cpp b/src/gui/wxMainFrame.cpp
index 58525ea..05473f9 100644
--- a/src/gui/wxMainFrame.cpp
+++ b/src/gui/wxMainFrame.cpp
@@ -55,9 +55,7 @@
 // view in the frame - with current wxGTK it doesn't work at all, so disabling
 #undef HAS_DYNAMIC_MENU_SUPPORT
 
-#ifdef DEBUG
-   #include "mail/FolderPool.h"
-#endif // DEBUG
+#include "mail/FolderPool.h"
 
 // ----------------------------------------------------------------------------
 // constants

commit 723dcb7f321e9358445e53c1856afb2668827547
Author: Vadim Zeitlin <[email protected]>
Date:   Mon Feb 13 18:14:44 2012 +0100

    Fix filter parsing code in presence of non-ASCII characters.
    
    We were getting asserts and wrong results when trying to read non-ASCII filter
    rules. Fix this by using std::string instead of wxString for storing the
    filter text as the code works with it as a sequence of bytes and not really as
    characters. This is, of course, not ideal, especially because we currently
    hard code the use of UTF-8 for converting wxString contents of the file into
    std::string (which is fine in practice as long as the file is really encoded
    in UTF-8) but better than nothing.

diff --git a/include/modules/Filters.h b/include/modules/Filters.h
index d016e1a..dbfa3dc 100644
--- a/include/modules/Filters.h
+++ b/include/modules/Filters.h
@@ -29,7 +29,7 @@ public:
      @param filterrule the text of the filter program
      @return a filter rule on success or NULL on error
    */
-   virtual FilterRule * GetFilter(const String &filterrule) const = 0;
+   virtual FilterRule * GetFilter(const char* filterrule) const = 0;
 
    /** To easily obtain a filter module: */
    static MModule_Filters *GetModule(void)
diff --git a/src/classes/MFilter.cpp b/src/classes/MFilter.cpp
index 532ddce..fb959d7 100644
--- a/src/classes/MFilter.cpp
+++ b/src/classes/MFilter.cpp
@@ -1156,7 +1156,7 @@ GetFilterForFolder(const MFolder *folder)
    }
 
    // compile the filter rule into the real filter
-   FilterRule *filterRule = filterModule->GetFilter(filterString);
+   FilterRule *filterRule = filterModule->GetFilter(filterString.utf8_str());
 
    // filterRule holds a reference to the filterModule if it was successfully
    // been created, otherwise we don't need filterModule anyhow
diff --git a/src/modules/Filters.cpp b/src/modules/Filters.cpp
index 4ed7c79..fc6a991 100644
--- a/src/modules/Filters.cpp
+++ b/src/modules/Filters.cpp
@@ -206,7 +206,7 @@ public:
    // implement the base class pure virtual
    virtual int Apply(MailFolder *folder, UIdArray& msgs);
 
-   static FilterRule * Create(const String &filterrule,
+   static FilterRule * Create(const char* filterrule,
                               MInterface *minterface,
                               MModule_Filters *mod)
       { return new FilterRuleImpl(filterrule, minterface, mod); }
@@ -215,13 +215,13 @@ public:
 #endif
 
 protected:
-   FilterRuleImpl(const String &filterrule,
+   FilterRuleImpl(const char* filterrule,
                   MInterface *minterface,
                   MModule_Filters *fmodule);
    ~FilterRuleImpl();
 
 public:
-   const SyntaxNode * Parse(const String &);
+   const SyntaxNode * Parse(const std::string &);
    const SyntaxNode * ParseProgram(void);
    const SyntaxNode * ParseFilters(void);
    const SyntaxNode * ParseIfElse(void);
@@ -300,22 +300,22 @@ protected:
    {
       return m_Position == m_Input.length()
                ? '\0'
-               : static_cast<char>(m_Input[m_Position]);
+               : m_Input[m_Position];
    }
    void EatWhiteSpace(void)
       { while(isspace(Char())) m_Position++; }
    char CharInc(void)
       { return m_Input[m_Position++]; }
-   String CharLeft(void)
-      { return m_Input.Left(m_Position); }
-   String CharMid(void)
-      { return m_Input.Mid(m_Position); }
+   std::string CharLeft(void)
+      { return std::string(m_Input, 0, m_Position); }
+   std::string CharMid(void)
+      { return std::string(m_Input, m_Position); }
 
 private:
    MModule_Filters *m_FilterModule;
    MInterface *m_MInterface;
 
-   String m_Input;
+   std::string m_Input;
    Token token;              // current token
    size_t m_Position;        // seek offset of current token
    size_t m_Peek;            // seek offset of next token
@@ -1065,11 +1065,9 @@ FilterRuleImpl::Error(const String &error)
 {
    MOcheck();
    unsigned long pos = GetPos();
-   String before, after, tmp;
-   before = m_Input.Left(pos);
-   after = m_Input.Mid(pos);
+   String tmp;
    tmp.Printf(_("Parse error at input position %lu:\n  %s\n%s<error> %s"),
-              pos, error.c_str(), before.c_str(), after.c_str());
+              pos, error.c_str(), CharLeft().c_str(), CharMid().c_str());
 
    // FIXME: this should be wxLogError() call as otherwise we get several
    //        message boxes for each error instead of only one combining all
@@ -1229,13 +1227,13 @@ FilterRuleImpl::Rewind(size_t pos)
    m_Position = pos;
 }
 
-static void PreProcessInput(String *input)
+static void PreProcessInput(std::string *input)
 {
    bool modified = false;
    String output;
-   while(input->Length() && input->c_str()[0] == '@')
+   while(input->length() && input->c_str()[0] == '@')
    {
-      const wxChar *cptr = input->c_str()+1;
+      const char *cptr = input->c_str()+1;
       String filename;
       while(*cptr && *cptr != '\n' && *cptr != '\r')
          filename += *cptr++;
@@ -1265,13 +1263,13 @@ static void PreProcessInput(String *input)
    if(modified)
    {
       *input = output;
-      if(input->Length())
+      if(input->length())
          PreProcessInput(input);
    }
 }
 
 const SyntaxNode *
-FilterRuleImpl::Parse(const String &input)
+FilterRuleImpl::Parse(const std::string &input)
 {
    MOcheck();
    /* Here we handle the one special occasion of input being @filename
@@ -2597,7 +2595,7 @@ FilterRuleImpl::Apply(MailFolder *mf, UIdArray& msgs)
    return rc;
 }
 
-FilterRuleImpl::FilterRuleImpl(const String &filterrule,
+FilterRuleImpl::FilterRuleImpl(const char* filterrule,
                                MInterface *minterface,
                                MModule_Filters *mod)
               : m_FilterModule(mod),
@@ -3199,7 +3197,7 @@ class MModule_FiltersImpl : public MModule_Filters
    /** Takes a string representation of a filterrule and compiles it
        into a class FilterRule object.
    */
-   virtual FilterRule * GetFilter(const String &filterrule) const;
+   virtual FilterRule * GetFilter(const char* filterrule) const;
    DEFAULT_ENTRY_FUNC
 protected:
    MModule_FiltersImpl()
@@ -3224,7 +3222,7 @@ MMODULE_BEGIN_IMPLEMENT(MModule_FiltersImpl,
 MMODULE_END_IMPLEMENT(MModule_FiltersImpl)
 
 FilterRule *
-MModule_FiltersImpl::GetFilter(const String &filterrule) const
+MModule_FiltersImpl::GetFilter(const char* filterrule) const
 {
    return FilterRuleImpl::Create(filterrule, m_MInterface,
                                  (MModule_FiltersImpl *) this);

-----------------------------------------------------------------------

Summary of changes:
 include/modules/Filters.h   |    2 +-
 src/classes/MFilter.cpp     |    2 +-
 src/gui/wxMainFrame.cpp     |    4 +---
 src/modules/Filters.cpp     |   40 +++++++++++++++++++---------------------
 src/modules/viewflt/PGP.cpp |    7 ++++++-
 5 files changed, 28 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
Mahogany sources repository.

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/