See ChangeLog
Monotone-Parent: c052846d400add7f419d4d1ffe4c900df5f4302a Monotone-Revision: f0940e9496d2f6b614f37aed2fd66c564c0df278 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-09-30T19:34:31 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
3b9ee48394
commit
53b31d9cce
|
@ -1,3 +1,8 @@
|
|||
2008-09-30 Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||
|
||||
* Implemented external loading of images
|
||||
in HTML mails the same way Thunderbird does it.
|
||||
|
||||
2008-09-30 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoLDAPUserDefaults.m ([SOGoLDAPUserDefaults
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -207,13 +207,18 @@ static NSString *mailETag = nil;
|
|||
inContext: (WOContext *) _ctx
|
||||
{
|
||||
UIxMailRenderingContext *mctx;
|
||||
WORequest *request;
|
||||
NSString *unsafe;
|
||||
|
||||
request = [_ctx request];
|
||||
unsafe = [request formValueForKey: @"unsafe"];
|
||||
|
||||
if (mailETag != nil)
|
||||
[[_ctx response] setHeader:mailETag forKey:@"etag"];
|
||||
|
||||
mctx = [[UIxMailRenderingContext alloc] initWithViewer: self
|
||||
context: _ctx];
|
||||
|
||||
[mctx setUnsafe: (unsafe != nil ? YES : NO)];
|
||||
[_ctx pushMailRenderingContext: mctx];
|
||||
[mctx release];
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
xmlns:rsrc="OGo:url"
|
||||
xmlns:label="OGo:label">
|
||||
<var:string value="cssContent" const:escapeHTML="NO" />
|
||||
<input type="hidden" name="displayLoadImages" const:id="displayLoadImages"
|
||||
var:value="displayLoadImages"/>
|
||||
<div class="SOGoHTMLMail-CSS-Delimiter mailer_htmlcontent"
|
||||
><var:string value="flatContentAsString" const:escapeHTML="NO" /></div>
|
||||
</container>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
><input const:name="editDraftButton" const:id="editDraftButton"
|
||||
type="button" class="button" label:value="Edit Draft..."
|
||||
/></var:if>
|
||||
<input const:name="loadImagesButton" const:id="loadImagesButton"
|
||||
type="button" class="button" label:value="Load Images"
|
||||
/>
|
||||
<table class="mailer_fieldtable">
|
||||
<tr class="mailer_fieldrow">
|
||||
<td class="mailer_fieldname" ><var:string label:value="Subject"/>:</td>
|
||||
|
|
|
@ -356,6 +356,13 @@ INPUT#editDraftButton
|
|||
right: 1em;
|
||||
}
|
||||
|
||||
INPUT#loadImagesButton
|
||||
{
|
||||
position: absolute;
|
||||
top: 2.5em;
|
||||
right: 1em;
|
||||
}
|
||||
|
||||
TABLE.mailer_fieldtable
|
||||
{ top: 0px;
|
||||
left: 0px;
|
||||
|
|
|
@ -752,6 +752,20 @@ function loadMessage(idx) {
|
|||
configureLinksInMessage();
|
||||
resizeMailContent();
|
||||
}
|
||||
|
||||
configureLoadImagesButton();
|
||||
}
|
||||
|
||||
function configureLoadImagesButton() {
|
||||
// We show/hide the "Load Images" button
|
||||
var loadImagesButton = $("loadImagesButton");
|
||||
var displayLoadImages = $("displayLoadImages");
|
||||
|
||||
if (typeof(displayLoadImages) == "undefined" ||
|
||||
displayLoadImages == null ||
|
||||
displayLoadImages.value == 0) {
|
||||
loadImagesButton.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function configureLinksInMessage() {
|
||||
|
@ -779,6 +793,11 @@ function configureLinksInMessage() {
|
|||
editDraftButton.observe("click",
|
||||
onMessageEditDraft.bindAsEventListener(editDraftButton));
|
||||
|
||||
var loadImagesButton = $("loadImagesButton");
|
||||
if (loadImagesButton)
|
||||
loadImagesButton.observe("click",
|
||||
onMessageLoadImages.bindAsEventListener(loadImagesButton));
|
||||
|
||||
configureiCalLinksInMessage();
|
||||
}
|
||||
|
||||
|
@ -885,6 +904,14 @@ function onMessageEditDraft(event) {
|
|||
return openMessageWindowsForSelection("edit", true);
|
||||
}
|
||||
|
||||
function onMessageLoadImages(event) {
|
||||
var msguid = Mailer.currentMessages[Mailer.currentMailbox];
|
||||
var url = (ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/"
|
||||
+ msguid + "/view?noframe=1&unsafe=1");
|
||||
document.messageAjaxRequest
|
||||
= triggerAjaxRequest(url, messageCallback, msguid);
|
||||
}
|
||||
|
||||
function onEmailAddressClick(event) {
|
||||
popupMenu(event, 'addressMenu', this);
|
||||
preventDefault(event);
|
||||
|
@ -910,7 +937,8 @@ function messageCallback(http) {
|
|||
div.update(http.responseText);
|
||||
configureLinksInMessage();
|
||||
resizeMailContent();
|
||||
|
||||
configureLoadImagesButton();
|
||||
|
||||
if (http.callbackData) {
|
||||
var cachedMessage = new Array();
|
||||
cachedMessage['idx'] = Mailer.currentMailbox + '/' + http.callbackData;
|
||||
|
|
Loading…
Reference in New Issue