From 133871a4a4dae1ad8bcd3013dc0dac69c7395445 Mon Sep 17 00:00:00 2001 From: Andreas Gungl Date: Fri, 8 Oct 2004 21:05:51 +0000 Subject: [PATCH] Fix searching when the header field in question is the first one of a message. CCMAIL: 90727-done@bugs.kde.org svn path=/trunk/kdepim/; revision=353015 --- kmsearchpattern.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kmsearchpattern.cpp b/kmsearchpattern.cpp index 5420552cb..991fd2dfe 100644 --- a/kmsearchpattern.cpp +++ b/kmsearchpattern.cpp @@ -173,7 +173,7 @@ KMSearchRuleString::KMSearchRuleString( const QCString & field, { if ( field.isEmpty() || field[0] == '<' ) mBmHeaderField = 0; - else //TODO handle the unrealistic case of the message starting with mField + else // make sure you handle the unrealistic case of the message starting with mField mBmHeaderField = new DwBoyerMoore(("\n" + field + ": ").data()); } @@ -237,7 +237,10 @@ bool KMSearchRuleString::matches( const DwString & aStr, KMMessage & msg, if ( endOfHeader == DwString::npos ) endOfHeader = lfcrlf.FindIn( aStr, 0 ); const DwString headers = ( endOfHeader == DwString::npos ) ? aStr : aStr.substr( 0, endOfHeader ); - size_t start = headerField->FindIn( headers, 0, false ); + // In case the searched header is at the beginning, we have to prepend + // a newline - see the comment in KMSearchRuleString constructor + DwString fakedHeaders( "\n" ); + size_t start = headerField->FindIn( fakedHeaders.append( headers ), 0, false ); // if the header field doesn't exist then return false for positive // functions and true for negated functions (e.g. "does not // contain"); note that all negated string functions correspond