Card view: don't escape <br>'s in note field

pull/58/head
Francis Lachapelle 2014-10-05 00:30:27 -04:00
parent f353b6d1c0
commit a0317046ba
2 changed files with 17 additions and 3 deletions

3
NEWS
View File

@ -2,7 +2,8 @@
------------------- -------------------
Bug fixes Bug fixes
- fix freebusy lookup with "Show time as busy" (#2930) - fixed freebusy lookup with "Show time as busy" (#2930)
- don't escape <br>'s in a card's note field
2.2.9a (2014-09-29) 2.2.9a (2014-09-29)
------------------- -------------------

View File

@ -67,15 +67,18 @@
- (NSString *) _cardStringWithLabel: (NSString *) label - (NSString *) _cardStringWithLabel: (NSString *) label
value: (NSString *) value value: (NSString *) value
byEscapingHTMLString: (BOOL) escapeHTML
asLinkScheme: (NSString *) scheme asLinkScheme: (NSString *) scheme
withLinkAttributes: (NSString *) attrs withLinkAttributes: (NSString *) attrs
{ {
NSMutableString *cardString; NSMutableString *cardString;
cardString = [NSMutableString stringWithCapacity: 80]; cardString = [NSMutableString stringWithCapacity: 80];
value = [[value stringByReplacingString: @"\r" withString: @""] stringByEscapingHTMLString]; value = [value stringByReplacingString: @"\r" withString: @""];
if ([value length] > 0) if ([value length] > 0)
{ {
if (escapeHTML)
value = [value stringByEscapingHTMLString];
if ([scheme length] > 0) if ([scheme length] > 0)
value = [NSString stringWithFormat: @"<a href=\"%@%@\" %@>%@</a>", scheme, value, attrs, value]; value = [NSString stringWithFormat: @"<a href=\"%@%@\" %@>%@</a>", scheme, value, attrs, value];
@ -94,6 +97,7 @@
{ {
return [self _cardStringWithLabel: label return [self _cardStringWithLabel: label
value: value value: value
byEscapingHTMLString: YES
asLinkScheme: nil asLinkScheme: nil
withLinkAttributes: nil]; withLinkAttributes: nil];
} }
@ -104,6 +108,7 @@
{ {
return [self _cardStringWithLabel: label return [self _cardStringWithLabel: label
value: value value: value
byEscapingHTMLString: YES
asLinkScheme: scheme asLinkScheme: scheme
withLinkAttributes: nil]; withLinkAttributes: nil];
} }
@ -144,6 +149,7 @@
return [self _cardStringWithLabel: @"Email:" return [self _cardStringWithLabel: @"Email:"
value: email value: email
byEscapingHTMLString: YES
asLinkScheme: @"mailto:" asLinkScheme: @"mailto:"
withLinkAttributes: attrs]; withLinkAttributes: attrs];
} }
@ -182,6 +188,7 @@
[secondaryEmails addObject: [self _cardStringWithLabel: nil [secondaryEmails addObject: [self _cardStringWithLabel: nil
value: email value: email
byEscapingHTMLString: YES
asLinkScheme: @"mailto:" asLinkScheme: @"mailto:"
withLinkAttributes: attrs]]; withLinkAttributes: attrs]];
} }
@ -365,6 +372,7 @@
return [self _cardStringWithLabel: nil return [self _cardStringWithLabel: nil
value: data value: data
byEscapingHTMLString: YES
asLinkScheme: schema asLinkScheme: schema
withLinkAttributes: @"target=\"_blank\""]; withLinkAttributes: @"target=\"_blank\""];
} }
@ -591,13 +599,18 @@
note = [card note]; note = [card note];
if (note) if (note)
{ {
note = [note stringByEscapingHTMLString];
note = [note stringByReplacingString: @"\r\n" note = [note stringByReplacingString: @"\r\n"
withString: @"<br />"]; withString: @"<br />"];
note = [note stringByReplacingString: @"\n" note = [note stringByReplacingString: @"\n"
withString: @"<br />"]; withString: @"<br />"];
} }
return [self _cardStringWithLabel: @"Note:" value: note]; return [self _cardStringWithLabel: @"Note:"
value: note
byEscapingHTMLString: NO
asLinkScheme: nil
withLinkAttributes: nil];
} }
/* hrefs */ /* hrefs */