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>
|
2008-09-30 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
* SoObjects/SOGo/SOGoLDAPUserDefaults.m ([SOGoLDAPUserDefaults
|
* SoObjects/SOGo/SOGoLDAPUserDefaults.m ([SOGoLDAPUserDefaults
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* UIxMailPartHTMLViewer.h - this file is part of SOGo
|
/* 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>
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
*
|
*
|
||||||
|
@ -28,9 +28,11 @@
|
||||||
@interface UIxMailPartHTMLViewer : UIxMailPartViewer
|
@interface UIxMailPartHTMLViewer : UIxMailPartViewer
|
||||||
{
|
{
|
||||||
id handler;
|
id handler;
|
||||||
|
BOOL unsafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) flatContentAsString;
|
- (NSString *) flatContentAsString;
|
||||||
|
- (void) setUnsafe: (BOOL) b;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,8 @@ _xmlCharsetForCharset (NSString *charset)
|
||||||
BOOL inScript;
|
BOOL inScript;
|
||||||
BOOL inCSSDeclaration;
|
BOOL inCSSDeclaration;
|
||||||
BOOL hasEmbeddedCSS;
|
BOOL hasEmbeddedCSS;
|
||||||
|
BOOL hasExternalImages;
|
||||||
|
BOOL unsafe;
|
||||||
NSMutableArray *crumb;
|
NSMutableArray *crumb;
|
||||||
xmlCharEncoding contentEncoding;
|
xmlCharEncoding contentEncoding;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +137,16 @@ _xmlCharsetForCharset (NSString *charset)
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasExternalImages
|
||||||
|
{
|
||||||
|
return hasExternalImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) setUnsafe: (BOOL) b
|
||||||
|
{
|
||||||
|
unsafe = b;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setContentEncoding: (xmlCharEncoding) newContentEncoding
|
- (void) setContentEncoding: (xmlCharEncoding) newContentEncoding
|
||||||
{
|
{
|
||||||
contentEncoding = newContentEncoding;
|
contentEncoding = newContentEncoding;
|
||||||
|
@ -292,8 +304,14 @@ _xmlCharsetForCharset (NSString *charset)
|
||||||
value = [attachmentIds objectForKey: cid];
|
value = [attachmentIds objectForKey: cid];
|
||||||
skipAttribute = (value == nil);
|
skipAttribute = (value == nil);
|
||||||
}
|
}
|
||||||
else
|
else if ([_rawName caseInsensitiveCompare: @"img"] == NSOrderedSame)
|
||||||
skipAttribute = YES;
|
{
|
||||||
|
hasExternalImages = YES;
|
||||||
|
|
||||||
|
if (!unsafe) skipAttribute = YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
skipAttribute = YES;
|
||||||
}
|
}
|
||||||
else if ([name caseInsensitiveCompare: @"href"] == NSOrderedSame
|
else if ([name caseInsensitiveCompare: @"href"] == NSOrderedSame
|
||||||
|| [name caseInsensitiveCompare: @"action"] == NSOrderedSame)
|
|| [name caseInsensitiveCompare: @"action"] == NSOrderedSame)
|
||||||
|
@ -520,10 +538,17 @@ _xmlCharsetForCharset (NSString *charset)
|
||||||
handler = [_UIxHTMLMailContentHandler new];
|
handler = [_UIxHTMLMailContentHandler new];
|
||||||
[handler setAttachmentIds: [mail fetchAttachmentIds]];
|
[handler setAttachmentIds: [mail fetchAttachmentIds]];
|
||||||
[handler setContentEncoding: [self _xmlCharEncoding]];
|
[handler setContentEncoding: [self _xmlCharEncoding]];
|
||||||
|
[handler setUnsafe: unsafe];
|
||||||
|
|
||||||
[parser setContentHandler: handler];
|
[parser setContentHandler: handler];
|
||||||
[parser parseFromSource: preparsedContent];
|
[parser parseFromSource: preparsedContent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasExternalImages
|
||||||
|
{
|
||||||
|
return [handler hasExternalImages];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) cssContent
|
- (NSString *) cssContent
|
||||||
{
|
{
|
||||||
NSString *cssContent, *css;
|
NSString *cssContent, *css;
|
||||||
|
@ -550,6 +575,23 @@ _xmlCharsetForCharset (NSString *charset)
|
||||||
return [handler result];
|
return [handler result];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setUnsafe: (BOOL) b
|
||||||
|
{
|
||||||
|
unsafe = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) displayLoadImages
|
||||||
|
{
|
||||||
|
BOOL b;
|
||||||
|
|
||||||
|
b = [handler hasExternalImages];
|
||||||
|
|
||||||
|
if (b && unsafe)
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation UIxMailPartExternalHTMLViewer
|
@implementation UIxMailPartExternalHTMLViewer
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
WOComponent *viewer; /* non-retained! */
|
WOComponent *viewer; /* non-retained! */
|
||||||
WOContext *context; /* non-retained! */
|
WOContext *context; /* non-retained! */
|
||||||
NSDictionary *flatContents; /* IMAP4 name to NSData */
|
NSDictionary *flatContents; /* IMAP4 name to NSData */
|
||||||
|
BOOL unsafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithViewer: (WOComponent *) _viewer
|
- (id) initWithViewer: (WOComponent *) _viewer
|
||||||
|
@ -51,6 +52,7 @@
|
||||||
/* state */
|
/* state */
|
||||||
|
|
||||||
- (void) reset;
|
- (void) reset;
|
||||||
|
- (void) setUnsafe: (BOOL) b;
|
||||||
|
|
||||||
/* fetching */
|
/* fetching */
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,11 @@ static BOOL showNamedTextAttachmentsInline = NO;
|
||||||
flatContents = nil;
|
flatContents = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setUnsafe: (BOOL) b
|
||||||
|
{
|
||||||
|
unsafe = b;
|
||||||
|
}
|
||||||
|
|
||||||
/* fetching */
|
/* fetching */
|
||||||
|
|
||||||
- (NSDictionary *) flatContents
|
- (NSDictionary *) flatContents
|
||||||
|
@ -152,7 +157,12 @@ static BOOL showNamedTextAttachmentsInline = NO;
|
||||||
|
|
||||||
- (WOComponent *) htmlViewer
|
- (WOComponent *) htmlViewer
|
||||||
{
|
{
|
||||||
return [viewer pageWithName: @"UIxMailPartHTMLViewer"];
|
id o;
|
||||||
|
|
||||||
|
o = [viewer pageWithName: @"UIxMailPartHTMLViewer"];
|
||||||
|
[o setUnsafe: unsafe];
|
||||||
|
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (WOComponent *) messageViewer
|
- (WOComponent *) messageViewer
|
||||||
|
@ -307,7 +317,8 @@ static BOOL showNamedTextAttachmentsInline = NO;
|
||||||
|
|
||||||
/* debugging */
|
/* debugging */
|
||||||
|
|
||||||
- (BOOL)isDebuggingEnabled {
|
- (BOOL) isDebuggingEnabled
|
||||||
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,10 +329,13 @@ static BOOL showNamedTextAttachmentsInline = NO;
|
||||||
|
|
||||||
static NSString *MRK = @"UIxMailRenderingContext";
|
static NSString *MRK = @"UIxMailRenderingContext";
|
||||||
|
|
||||||
- (void)pushMailRenderingContext:(UIxMailRenderingContext *)_mctx {
|
- (void) pushMailRenderingContext: (UIxMailRenderingContext *) _mctx
|
||||||
|
{
|
||||||
[self setObject:_mctx forKey:MRK];
|
[self setObject:_mctx forKey:MRK];
|
||||||
}
|
}
|
||||||
- (UIxMailRenderingContext *)popMailRenderingContext {
|
|
||||||
|
- (UIxMailRenderingContext *) popMailRenderingContext
|
||||||
|
{
|
||||||
UIxMailRenderingContext *mctx;
|
UIxMailRenderingContext *mctx;
|
||||||
|
|
||||||
if ((mctx = [self objectForKey:MRK]) == nil)
|
if ((mctx = [self objectForKey:MRK]) == nil)
|
||||||
|
@ -331,7 +345,9 @@ static NSString *MRK = @"UIxMailRenderingContext";
|
||||||
[self removeObjectForKey:MRK];
|
[self removeObjectForKey:MRK];
|
||||||
return mctx;
|
return mctx;
|
||||||
}
|
}
|
||||||
- (UIxMailRenderingContext *)mailRenderingContext {
|
|
||||||
|
- (UIxMailRenderingContext *) mailRenderingContext
|
||||||
|
{
|
||||||
return [self objectForKey:MRK];
|
return [self objectForKey:MRK];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,13 +207,18 @@ static NSString *mailETag = nil;
|
||||||
inContext: (WOContext *) _ctx
|
inContext: (WOContext *) _ctx
|
||||||
{
|
{
|
||||||
UIxMailRenderingContext *mctx;
|
UIxMailRenderingContext *mctx;
|
||||||
|
WORequest *request;
|
||||||
|
NSString *unsafe;
|
||||||
|
|
||||||
|
request = [_ctx request];
|
||||||
|
unsafe = [request formValueForKey: @"unsafe"];
|
||||||
|
|
||||||
if (mailETag != nil)
|
if (mailETag != nil)
|
||||||
[[_ctx response] setHeader:mailETag forKey:@"etag"];
|
[[_ctx response] setHeader:mailETag forKey:@"etag"];
|
||||||
|
|
||||||
mctx = [[UIxMailRenderingContext alloc] initWithViewer: self
|
mctx = [[UIxMailRenderingContext alloc] initWithViewer: self
|
||||||
context: _ctx];
|
context: _ctx];
|
||||||
|
[mctx setUnsafe: (unsafe != nil ? YES : NO)];
|
||||||
[_ctx pushMailRenderingContext: mctx];
|
[_ctx pushMailRenderingContext: mctx];
|
||||||
[mctx release];
|
[mctx release];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
xmlns:rsrc="OGo:url"
|
xmlns:rsrc="OGo:url"
|
||||||
xmlns:label="OGo:label">
|
xmlns:label="OGo:label">
|
||||||
<var:string value="cssContent" const:escapeHTML="NO" />
|
<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"
|
<div class="SOGoHTMLMail-CSS-Delimiter mailer_htmlcontent"
|
||||||
><var:string value="flatContentAsString" const:escapeHTML="NO" /></div>
|
><var:string value="flatContentAsString" const:escapeHTML="NO" /></div>
|
||||||
</container>
|
</container>
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
><input const:name="editDraftButton" const:id="editDraftButton"
|
><input const:name="editDraftButton" const:id="editDraftButton"
|
||||||
type="button" class="button" label:value="Edit Draft..."
|
type="button" class="button" label:value="Edit Draft..."
|
||||||
/></var:if>
|
/></var:if>
|
||||||
|
<input const:name="loadImagesButton" const:id="loadImagesButton"
|
||||||
|
type="button" class="button" label:value="Load Images"
|
||||||
|
/>
|
||||||
<table class="mailer_fieldtable">
|
<table class="mailer_fieldtable">
|
||||||
<tr class="mailer_fieldrow">
|
<tr class="mailer_fieldrow">
|
||||||
<td class="mailer_fieldname" ><var:string label:value="Subject"/>:</td>
|
<td class="mailer_fieldname" ><var:string label:value="Subject"/>:</td>
|
||||||
|
|
|
@ -356,6 +356,13 @@ INPUT#editDraftButton
|
||||||
right: 1em;
|
right: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INPUT#loadImagesButton
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
top: 2.5em;
|
||||||
|
right: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
TABLE.mailer_fieldtable
|
TABLE.mailer_fieldtable
|
||||||
{ top: 0px;
|
{ top: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
|
|
|
@ -752,6 +752,20 @@ function loadMessage(idx) {
|
||||||
configureLinksInMessage();
|
configureLinksInMessage();
|
||||||
resizeMailContent();
|
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() {
|
function configureLinksInMessage() {
|
||||||
|
@ -779,6 +793,11 @@ function configureLinksInMessage() {
|
||||||
editDraftButton.observe("click",
|
editDraftButton.observe("click",
|
||||||
onMessageEditDraft.bindAsEventListener(editDraftButton));
|
onMessageEditDraft.bindAsEventListener(editDraftButton));
|
||||||
|
|
||||||
|
var loadImagesButton = $("loadImagesButton");
|
||||||
|
if (loadImagesButton)
|
||||||
|
loadImagesButton.observe("click",
|
||||||
|
onMessageLoadImages.bindAsEventListener(loadImagesButton));
|
||||||
|
|
||||||
configureiCalLinksInMessage();
|
configureiCalLinksInMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,6 +904,14 @@ function onMessageEditDraft(event) {
|
||||||
return openMessageWindowsForSelection("edit", true);
|
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) {
|
function onEmailAddressClick(event) {
|
||||||
popupMenu(event, 'addressMenu', this);
|
popupMenu(event, 'addressMenu', this);
|
||||||
preventDefault(event);
|
preventDefault(event);
|
||||||
|
@ -910,7 +937,8 @@ function messageCallback(http) {
|
||||||
div.update(http.responseText);
|
div.update(http.responseText);
|
||||||
configureLinksInMessage();
|
configureLinksInMessage();
|
||||||
resizeMailContent();
|
resizeMailContent();
|
||||||
|
configureLoadImagesButton();
|
||||||
|
|
||||||
if (http.callbackData) {
|
if (http.callbackData) {
|
||||||
var cachedMessage = new Array();
|
var cachedMessage = new Array();
|
||||||
cachedMessage['idx'] = Mailer.currentMailbox + '/' + http.callbackData;
|
cachedMessage['idx'] = Mailer.currentMailbox + '/' + http.callbackData;
|
||||||
|
|
Loading…
Reference in New Issue