Adium

Changeset 23116

Show
Ignore:
Timestamp:
04/12/2008 01:52:22 PM (7 months ago)
Author:
evands
Message:

Merged [23115]: We'll be running message through an HTML decoder. If we unescape all entities, we end up treating any typed HTML code as a real HTML code, because for example &lt;/html&gt; becomes </html> before the decoder even sees it. That's bad.

We apparently need to unescape ampersand immediately (I didn't retest that claim, made in #6850). We'll just do that rather than a full unescaping. Note that we can't use stringByUnescapingFromXMLWithEntities: with a dictionary specifying just the ampersand, the documentation for CFXMLCreateStringByUnescapingEntities(), which that method wraps, states "The standard XML entities are always replaced".

Fixes #9591

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/adium-1.2/Source/GBChatlogHTMLConverter.m

    r21996 r23116  
    237237                                NSString *message = nil; 
    238238                                if (!empty) { 
    239                                         // Need to unescape entities ourself. & wasn't getting unescaped for some reason. See #6850. 
    240                                         // 10 for </message> and 1 for the index being off 
    241                                         message = [[inputFileString substringWithRange:NSMakeRange(messageStart, end - messageStart - 11)] stringByUnescapingFromXMLWithEntities:nil]; 
     239                                        /* Need to unescape & now so that we'll do link detection properly when decoding the HTML. See #6850. 
     240                                         * We'll let HTML decoding handle the other entities. 
     241                                         * 
     242                                         * 11 = 10 for </message> and 1 for the index being off 
     243                                         */ 
     244                                        NSMutableString *mutableMessage = [[inputFileString substringWithRange:NSMakeRange(messageStart, end - messageStart - 11)] mutableCopy]; 
     245                                        [mutableMessage replaceOccurrencesOfString:@"&amp;" 
     246                                                                                                        withString:@"&" 
     247                                                                                                           options:NSLiteralSearch 
     248                                                                                                                 range:NSMakeRange(0, [mutableMessage length])]; 
     249                                        message = [mutableMessage autorelease]; 
    242250                                } 
    243251                                NSString *shownSender = sender;