adium 3536:43332e397ff6: Patch from kbotc to close all open <FON...
commits at adium.im
commits at adium.im
Tue Nov 16 02:08:52 UTC 2010
details: http://hg.adium.im/adium/rev/43332e397ff6
revision: 3536:43332e397ff6
author: Evan Schoenberg
date: Mon Nov 15 20:08:46 2010 -0600
Patch from kbotc to close all open <FONT> tags when encoding html via `-[AIHTMLDecoder encodeLooseHTML:imagesPath:]` rather than just closing one. Fixes issues with some message styles.
diffs (72 lines):
diff -r 13d5080c2da4 -r 43332e397ff6 Frameworks/Adium Framework/Source/AIHTMLDecoder.m
--- a/Frameworks/Adium Framework/Source/AIHTMLDecoder.m Mon Nov 15 19:27:55 2010 -0600
+++ b/Frameworks/Adium Framework/Source/AIHTMLDecoder.m Mon Nov 15 20:08:46 2010 -0600
@@ -207,10 +207,10 @@
- (NSString *)encodeLooseHTML:(NSAttributedString *)inMessage imagesPath:(NSString *)imagesSavePath
{
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
- NSRange searchRange;
+ NSFontManager *fontManager = [NSFontManager sharedFontManager];
+ NSRange searchRange;
NSColor *pageColor = nil;
- BOOL openFontTag = NO;
+ NSInteger *openFontTags = 0;
//Setup the incoming message as a regular string, and get its length
NSString *inMessageString = [inMessage string];
@@ -308,12 +308,14 @@
changedColor || changedBackColor) {
//Close any existing font tags, and open a new one
- if (thingsToInclude.closingFontTags && openFontTag) {
- [string appendString:@"</FONT>"];
- openFontTag = NO;
+ if (thingsToInclude.closingFontTags && (openFontTags > 0)) {
+ while (openFontTags > 0) {
+ [string appendString:@"</FONT>"];
+ openFontTags--;
+ }
}
if (!thingsToInclude.simpleTagsOnly) {
- openFontTag = YES;
+ openFontTags++;
//Leave the <FONT open since we'll add the rest of the font tag on below
[string appendString:@"<FONT"];
}
@@ -321,7 +323,7 @@
//Family
if (thingsToInclude.fontTags && familyName && (![familyName isEqualToString:currentFamily] || thingsToInclude.closingFontTags)) {
if (thingsToInclude.simpleTagsOnly) {
- openFontTag = YES;
+ openFontTags++;
[string appendString:[NSString stringWithFormat:@"<FONT FACE=\"%@\">",familyName]];
} else {
//(traits | NSNonStandardCharacterSetFontMask) seems to be the proper test... but it is true for all fonts!
@@ -346,7 +348,7 @@
//Color
if (color) {
if (thingsToInclude.simpleTagsOnly) {
- openFontTag = YES;
+ openFontTags++;
[string appendString:[NSString stringWithFormat:@"<FONT COLOR=\"#%@\">",color]];
} else {
[string appendString:[NSString stringWithFormat:@" COLOR=\"#%@\"",color]];
@@ -676,11 +678,14 @@
oldLink = nil;
}
- if (thingsToInclude.closingFontTags && openFontTag) {
+ if (thingsToInclude.closingFontTags && (openFontTags > 0)) {
//Close any open font tag
- [string appendString:@"</FONT>"];
- openFontTag = NO;
+ while (openFontTags > 0) {
+ [string appendString:@"</FONT>"];
+ openFontTags--;
+ }
}
+
if (rightToLeft) {
//Close any open div
[string appendString:@"</DIV>"];
More information about the commits
mailing list