[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: [Bug 94601] Wrong warning for external references
From: Ingo "Klöcker" <kloecker () kde ! org>
Date: 2004-12-30 0:10:48
Message-ID: 20041230001048.28959.qmail () ktown ! kde ! org
[Download RAW message or body]
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=94601
kloecker kde org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From kloecker kde org 2004-12-30 01:10 -------
CVS commit by kloecker:
Only show the 'External references' warning (with possibility to load them) if the \
HTML message contains obvious external references. BUG:94601
M +40 -2 objecttreeparser.cpp 1.125
M +6 -0 objecttreeparser.h 1.43
--- kdepim/kmail/objecttreeparser.h #1.42:1.43
@ -201,4 +201,10 @ namespace KMail {
bool processMailmanMessage( partNode * node );
+ /** Checks whether p str contains external references. To be precise,
+ we only check whether p str contains 'xxx="http[s]:' where xxx is
+ not href. Obfuscated external references are ignored on purpose.
+ */
+ static bool containsExternalReferences( const QCString & str );
+
public:// (during refactoring)
--- kdepim/kmail/objecttreeparser.cpp #1.124:1.125
@ -746,4 +746,35 @ bool ObjectTreeParser::okDecryptMIME( pa
}
+ //static
+ bool ObjectTreeParser::containsExternalReferences( const QCString & str )
+ {
+ int httpPos = str.find( "\"http:", 0, true );
+ int httpsPos = str.find( "\"https:", 0, true );
+
+ while ( httpPos >= 0 || httpsPos >= 0 ) {
+ // pos = index of next occurrence of "http: or "https: whichever comes first
+ int pos = ( httpPos < httpsPos )
+ ? ( ( httpPos >= 0 ) ? httpPos : httpsPos )
+ : ( ( httpsPos >= 0 ) ? httpsPos : httpPos );
+ // look backwards for "href"
+ if ( pos > 5 ) {
+ int hrefPos = str.findRev( "href", pos - 5, true );
+ // if no 'href' is found or the distance between 'href' and '"http[s]:'
+ // is larger than 7 (7 is the distance in 'href = "http[s]:') then
+ // we assume that we have found an external reference
+ if ( ( hrefPos == -1 ) || ( pos - hrefPos > 7 ) )
+ return true;
+ }
+ // find next occurrence of "http: or "https:
+ if ( pos == httpPos ) {
+ httpPos = str.find( "\"http:", httpPos + 6, true );
+ }
+ else {
+ httpsPos = str.find( "\"https:", httpsPos + 7, true );
+ }
+ }
+ return false;
+ }
+
bool ObjectTreeParser::processTextHtmlSubtype( partNode * curNode, ProcessResult & \
) { QCString cstr( curNode->msgPart().bodyDecoded() );
@ -776,5 +807,12 @ bool ObjectTreeParser::okDecryptMIME( pa
}
// ---Sven's strip </BODY> and </HTML> from end of attachment end-
- if ( !mReader->htmlLoadExternal() ) {
+ // Show the "external references" warning (with possibility to load
+ // external references only if loading external references is disabled
+ // and the HTML code contains obvious external references). For
+ // messages where the external references are obfuscated the user won't
+ // have an easy way to load them but that shouldn't be a problem
+ // because only spam contains obfuscated external references.
+ if ( !mReader->htmlLoadExternal() &&
+ containsExternalReferences( cstr ) ) {
htmlWriter()->queue( "<div class=\"htmlWarn\">\n" );
htmlWriter()->queue( i18n("<b>Note:</b> This HTML message may contain \
external " _______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic