From 928fe006a8a8baf20e686266d3a3be71c1aade7e Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 24 Apr 2025 21:42:46 -0700 Subject: [PATCH] Make maxEntityLength the actual length of the longest entity name in the entities dictionary. --- .../RSParser/Sources/ObjC/NSString+RSParser.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Modules/RSParser/Sources/ObjC/NSString+RSParser.m b/Modules/RSParser/Sources/ObjC/NSString+RSParser.m index 1d16474b0..984c1da66 100755 --- a/Modules/RSParser/Sources/ObjC/NSString+RSParser.m +++ b/Modules/RSParser/Sources/ObjC/NSString+RSParser.m @@ -165,11 +165,19 @@ static NSString *RSParserStringWithValue(uint32_t value); NSString *s = self.string; NSUInteger initialScanLocation = self.scanLocation; - static NSUInteger maxEntityLength = 20; // It’s probably smaller, but this is just for sanity. - + unichar ch = 0; + + static NSUInteger maxEntityLength = 0; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + for (NSString *entityName in RSEntitiesDictionary().allKeys) { + maxEntityLength = MAX(maxEntityLength, entityName.length); + } + }); + while (true) { - - unichar ch = [s characterAtIndex:self.scanLocation]; + + ch = [s characterAtIndex:self.scanLocation]; if ([NSCharacterSet.whitespaceAndNewlineCharacterSet characterIsMember:ch]) { break; } @@ -272,6 +280,7 @@ static NSDictionary *RSEntitiesDictionary(void) { @"cedil": @"¸", @"cent": @"¢", @"copy": @"©", + @"CounterClockwiseContourIntegral": @"∳", @"curren": @"¤", @"deg": @"°", @"die": @"¨",