[Kde-pim] Review Request: Remove all the signature blocks.

Thomas McGuire mcguire at kde.org
Wed Mar 25 16:33:13 GMT 2009



> On 2009-03-25 03:06:02, Jaime Torres wrote:
> > Modifying the regular expresion to "-- $", the sql comments are not Signature Blocks.
> > A question:
> > What do you prefer: To remove text replies or to not remove signature blocks completely?
> > In the current implementation, if there is a reply block without signature, between parts with signature blocks, it is removed.
> > Another possibility is to check only for prefix change (even in the case the signature contains > as a prefix), removing only part of the signature.
> > 
> > I do not see a solution to remove them completely if they contains the common reply characters as part of them, like:
> > 
> > text
> > "-- " (The " are there only to remark the space)
> > >This is a "not very good signature block"
> > >
> > > Reply text
> > >> Reply Reply text
> > >> "-- "
> > >> #Signature Block
> >

Ok, good that the "-- $" solves the case of the SQL comment.

Honestly I'm a bit lost now with the question. Can you give an example of both cases? Probably best to just implement the easier one.
The patch you attached does not apply cleanly, there is some problem with it, please upload a new one.


- Thomas


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.kde.org/r/403/#review613
-----------------------------------------------------------


On 2009-03-25 04:29:41, Jaime Torres wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.kde.org/r/403/
> -----------------------------------------------------------
> 
> (Updated 2009-03-25 04:29:41)
> 
> 
> Review request for KDE PIM.
> 
> 
> Summary
> -------
> 
> Remove all the signature blocks.
> The algorithm is:
> Look for the prefixes before the "-- " marks (i.e. the text before it in the line).
> foreach line, if the line contains "-- ", start to delete lines until the prefix changes.
> 
> (it should also work with c code if the -- is not followed by a space).
> 
> 
> This addresses bug 72316.
>     https://bugs.kde.org/show_bug.cgi?id=72316
> 
> 
> Diffs
> -----
> 
>   /trunk/KDE/kdepim/kmail/kmmessage.cpp 940552 
> 
> Diff: http://reviewboard.kde.org/r/403/diff
> 
> 
> Testing
> -------
> 
> #include <QtCore/QtCore>
> #include <iostream>
> 
> using namespace std;
> 
> static QString stripSignature ( const QString & msg, bool clearSigned )
> {
>   QRegExp SBDelimiterSearch = QRegExp( "-- $" );
>   QRegExp CommonReplySearch = QRegExp( "[>|']" );
>   
> 
>   // Split the string by line breaks
>   QStringList lines = msg.split( '\n' );
>   // Now, walk thougth the list again deleting from the "-- "$ until a prefix change.
>   // including empty prefixes and prefixes contained into other prefixes
> 
>   int i = 0;
> 
>   while ( i < lines.size() )
>   {
>     // look for the delimiter "-- "$
>     int posSignatureBlock = lines[i].indexOf( SBDelimiterSearch );
> 
>     if ( posSignatureBlock >= 0 )
>     {
>       // The prefix before "-- "$, for example, in ">> -- " is ">> "
>       const QString prefix = lines[i].left( posSignatureBlock );
>       lines.removeAt( i ); // removes the line "-- "$
> 
>       while ( i < lines.size() ) // lines srinks when a SB line is deleted
>       {
>         // remove the line of the Signature Block (SB)
>         if ( (lines[i].startsWith( prefix )) && (lines[i].indexOf( CommonReplySearch, posSignatureBlock) != posSignatureBlock ))
>           lines.removeAt( i );
>         else
>           break;
>       }
>     }
> 
>     ++i;
>   }
> 
>   // Join the lines and return the result.
>   return lines.join( "\n" );
> }
> 
> const QString testmail = "text1\n-- \nSignature Block1\nSignature Block1\n\n"\
>   "> text2\n> -- \n> Signature Block 2\n> Signature Block 2\n"
>   ">> text3 -- not a signature block\n>> text3\n"\
>   ">>> text4\n> -- \n> Signature Block 4\n> Signature Block 4\n"
>   ">>-------------\n>>-- text5 --\n>>-------------------\n>> -- \n>> Signature Block 5\n"
>   "text6\n-- \nSignature Block 6";
> const QString testmailExpected="text1\n"\
>   "> text2\n"
>   ">> text3 -- not a signature block\n>> text3\n"\
>   ">>> text4\n"
>   ">>-------------\n>>-- text5 --\n>>-------------------\n"
>   "text6";
> const QString testmail1 = "text1\n-- \nSignature Block1\nSignature Block1\n\n"
>   ">text2\n>-- \n>Signature Block 2\n>Signature Block 2\n"
>   "> >text3\n> >text3\n> >-- \n>>Signature Block 3\n> >Signature Block 3\n"
>   ">text4\n>-- \n>Signature Block 4\n>Signature Block 4\n"
>   "text5\n-- \nSignature Block 5";
> const QString testmail1Expected = "text1\n"
>   ">text2\n"
>   ">>Signature Block 3\n> >Signature Block 3\n"
>   ">text4\n"
>   "text5";
> // The first reply does not contains a signature block
> // but the second repy does.
> const QString testmail2 = "Text 1\n-- \nFirst sign\n\n\n> From: bla\n"
>   "> Texto 2\n\n> Aqui algo de texto.\n\n>> --\n>> Not Signature Block 2\n\n> Adios\n"
>   "\n>> Texto 3\n\n>> --\n>> Signature block 3\n";
> const QString testmail2Expected = "Text 1\n> From: bla\n"
>   "> Texto 2\n\n> Aqui algo de texto.\n\n>> --\n>> Not Signature Block 2\n\n> Adios\n"
>   "\n>> Texto 3\n\n>> --\n>> Signature block 3\n";
> 
> const QString testmail3 = "-- \n-- ACME, Inc\n-- Joe User\n-- PHB\n-- Tel.: 555 1234\n--";
> const QString testmail3Expected = "";
> 
> int
> main ( int argc, const char *argv[] )
> {
> 
>   QString res = stripSignature( testmail, 1 );
>   cout << "res:\n" << res.toStdString() << endl << "expected:\n" << testmailExpected.toStdString() << endl;
>   assert( res == testmailExpected);
>   res = stripSignature( testmail1, 1 );
>   cout << "res:\n" << res.toStdString() << endl << "expected:\n" <<  testmail1Expected.toStdString() << endl;
>   assert( res == testmail1Expected);
>   res = stripSignature( testmail3, 1 );
>   cout << "res:\n" << res.toStdString() << endl << "expected:\n" <<  testmail3Expected.toStdString() << endl;
>   assert( res == testmail3Expected);
>   res = stripSignature( testmail2, 1 );
>   cout << "res:\n" << res.toStdString() << endl << "expected:\n" <<  testmail2Expected.toStdString() << endl;
>   assert( res == testmail2Expected);
> 
> }
> 
> 
> Thanks,
> 
> Jaime
> 
>

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list