Skip to content

Commit feccd72

Browse files
committed
Merge branch 'mandersen-ios6-empty-node-crash' into develop
2 parents 620194a + 0deed07 commit feccd72

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

Core/Source/DTCoreTextParagraphStyle.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ + (DTCoreTextParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphSty
4343
#if DTCORETEXT_SUPPORT_NS_ATTRIBUTES
4444
+ (DTCoreTextParagraphStyle *)paragraphStyleWithNSParagraphStyle:(NSParagraphStyle *)paragraphStyle
4545
{
46-
NSParameterAssert(paragraphStyle);
46+
if ( ! paragraphStyle) {
47+
paragraphStyle = [NSParagraphStyle defaultParagraphStyle];
48+
}
4749

4850
DTCoreTextParagraphStyle *retStyle = [[DTCoreTextParagraphStyle alloc] init];
4951

Test/Source/NSAttributedStringHTMLTest.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,16 @@ - (void)testAttributedStringColorToHTML
170170
}
171171
*/
172172

173+
- (void)testCrashAtEmptyNodeBeforeDivWithiOS6Attributes
174+
{
175+
// This string is the simplest case that caused the crash.
176+
NSString *html = @"<div><i></i><div></div></div>;";
177+
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
178+
NSDictionary *options = @{DTUseiOS6Attributes: @(YES)};
179+
NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data
180+
options:options
181+
documentAttributes:NULL];
182+
XCTAssert(string != nil);
183+
}
184+
173185
@end

0 commit comments

Comments
 (0)