See ChangeLog

Monotone-Parent: c052846d400add7f419d4d1ffe4c900df5f4302a
Monotone-Revision: f0940e9496d2f6b614f37aed2fd66c564c0df278

Monotone-Author: ludovic@Sophos.ca
Monotone-Date: 2008-09-30T19:34:31
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Ludovic Marcotte
2008-09-30 19:34:31 +00:00
parent 3b9ee48394
commit 53b31d9cce
10 changed files with 122 additions and 10 deletions
+3 -1
View File
@@ -1,6 +1,6 @@
/* UIxMailPartHTMLViewer.h - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
* Copyright (C) 2007, 2008 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@@ -28,9 +28,11 @@
@interface UIxMailPartHTMLViewer : UIxMailPartViewer
{
id handler;
BOOL unsafe;
}
- (NSString *) flatContentAsString;
- (void) setUnsafe: (BOOL) b;
@end
+44 -2
View File
@@ -103,6 +103,8 @@ _xmlCharsetForCharset (NSString *charset)
BOOL inScript;
BOOL inCSSDeclaration;
BOOL hasEmbeddedCSS;
BOOL hasExternalImages;
BOOL unsafe;
NSMutableArray *crumb;
xmlCharEncoding contentEncoding;
}
@@ -135,6 +137,16 @@ _xmlCharsetForCharset (NSString *charset)
[super dealloc];
}
- (BOOL) hasExternalImages
{
return hasExternalImages;
}
- (BOOL) setUnsafe: (BOOL) b
{
unsafe = b;
}
- (void) setContentEncoding: (xmlCharEncoding) newContentEncoding
{
contentEncoding = newContentEncoding;
@@ -292,8 +304,14 @@ _xmlCharsetForCharset (NSString *charset)
value = [attachmentIds objectForKey: cid];
skipAttribute = (value == nil);
}
else
skipAttribute = YES;
else if ([_rawName caseInsensitiveCompare: @"img"] == NSOrderedSame)
{
hasExternalImages = YES;
if (!unsafe) skipAttribute = YES;
}
else
skipAttribute = YES;
}
else if ([name caseInsensitiveCompare: @"href"] == NSOrderedSame
|| [name caseInsensitiveCompare: @"action"] == NSOrderedSame)
@@ -520,10 +538,17 @@ _xmlCharsetForCharset (NSString *charset)
handler = [_UIxHTMLMailContentHandler new];
[handler setAttachmentIds: [mail fetchAttachmentIds]];
[handler setContentEncoding: [self _xmlCharEncoding]];
[handler setUnsafe: unsafe];
[parser setContentHandler: handler];
[parser parseFromSource: preparsedContent];
}
- (BOOL) hasExternalImages
{
return [handler hasExternalImages];
}
- (NSString *) cssContent
{
NSString *cssContent, *css;
@@ -550,6 +575,23 @@ _xmlCharsetForCharset (NSString *charset)
return [handler result];
}
- (void) setUnsafe: (BOOL) b
{
unsafe = b;
}
- (BOOL) displayLoadImages
{
BOOL b;
b = [handler hasExternalImages];
if (b && unsafe)
return NO;
return b;
}
@end
@implementation UIxMailPartExternalHTMLViewer
@@ -43,6 +43,7 @@
WOComponent *viewer; /* non-retained! */
WOContext *context; /* non-retained! */
NSDictionary *flatContents; /* IMAP4 name to NSData */
BOOL unsafe;
}
- (id) initWithViewer: (WOComponent *) _viewer
@@ -51,6 +52,7 @@
/* state */
- (void) reset;
- (void) setUnsafe: (BOOL) b;
/* fetching */
+21 -5
View File
@@ -86,6 +86,11 @@ static BOOL showNamedTextAttachmentsInline = NO;
flatContents = nil;
}
- (void) setUnsafe: (BOOL) b
{
unsafe = b;
}
/* fetching */
- (NSDictionary *) flatContents
@@ -152,7 +157,12 @@ static BOOL showNamedTextAttachmentsInline = NO;
- (WOComponent *) htmlViewer
{
return [viewer pageWithName: @"UIxMailPartHTMLViewer"];
id o;
o = [viewer pageWithName: @"UIxMailPartHTMLViewer"];
[o setUnsafe: unsafe];
return o;
}
- (WOComponent *) messageViewer
@@ -307,7 +317,8 @@ static BOOL showNamedTextAttachmentsInline = NO;
/* debugging */
- (BOOL)isDebuggingEnabled {
- (BOOL) isDebuggingEnabled
{
return NO;
}
@@ -318,10 +329,13 @@ static BOOL showNamedTextAttachmentsInline = NO;
static NSString *MRK = @"UIxMailRenderingContext";
- (void)pushMailRenderingContext:(UIxMailRenderingContext *)_mctx {
- (void) pushMailRenderingContext: (UIxMailRenderingContext *) _mctx
{
[self setObject:_mctx forKey:MRK];
}
- (UIxMailRenderingContext *)popMailRenderingContext {
- (UIxMailRenderingContext *) popMailRenderingContext
{
UIxMailRenderingContext *mctx;
if ((mctx = [self objectForKey:MRK]) == nil)
@@ -331,7 +345,9 @@ static NSString *MRK = @"UIxMailRenderingContext";
[self removeObjectForKey:MRK];
return mctx;
}
- (UIxMailRenderingContext *)mailRenderingContext {
- (UIxMailRenderingContext *) mailRenderingContext
{
return [self objectForKey:MRK];
}