Skip to content

Commit 83e0462

Browse files
committed
Merge branch 'release-1.6.24'
2 parents e9cc5bb + 5e192b2 commit 83e0462

18 files changed

+200
-74
lines changed

Core/Source/DTCoreTextLayoutFrameAccessibilityElementGenerator.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ - (DTAccessibilityElement *)accessibilityElementForTextInAttributedString:(NSAtt
7777
element.accessibilityLabel = text;
7878
element.localCoordinateAccessibilityFrame = [self frameForRuns:runs];
7979

80-
// We're trying to keep the accessibility frame behavior consistent with UIWebView, which seems to do a union of the rects for all the runs composing a single accessibility group,
80+
// We're trying to keep the accessibility frame behavior consistent with web view, which seems to do a union of the rects for all the runs composing a single accessibility group,
8181
// even if that spans across multiple lines. Set the local coordinate activation point to support multi-line links. A link that is at the end of one line and
8282
// wraps to the beginning of the next would have a rect that's the size of both lines combined. The center of that rect would be outside the hit areas for either of the
8383
// runs individually, so we set the accessibility activation point to be the origin of the first run.

Core/Source/DTHTMLAttributedStringBuilder.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,11 @@ - (void)_registerTagStartHandlers
422422
}
423423

424424
NSURL *link = [NSURL URLWithString:cleanString];
425-
if (link == nil) {
426-
link = [NSURL URLWithString:[cleanString stringByURLEncoding]];
425+
426+
if (link == nil)
427+
{
428+
cleanString = [cleanString stringByEncodingNonASCIICharacters];
429+
link = [NSURL URLWithString:cleanString];
427430
}
428431

429432
// deal with relative URL

Core/Source/DTHTMLElement.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,15 +1572,15 @@ - (void)interpretAttributes
15721572

15731573
if ([directionStr isEqualToString:@"rtl"])
15741574
{
1575-
_paragraphStyle.baseWritingDirection = NSWritingDirectionRightToLeft;
1575+
_paragraphStyle.baseWritingDirection = kCTWritingDirectionRightToLeft;
15761576
}
15771577
else if ([directionStr isEqualToString:@"ltr"])
15781578
{
1579-
_paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
1579+
_paragraphStyle.baseWritingDirection = kCTWritingDirectionLeftToRight;
15801580
}
15811581
else if ([directionStr isEqualToString:@"auto"])
15821582
{
1583-
_paragraphStyle.baseWritingDirection = NSWritingDirectionNatural; // that's also default
1583+
_paragraphStyle.baseWritingDirection = kCTWritingDirectionNatural; // that's also default
15841584
}
15851585
else
15861586
{

Core/Source/NSCharacterSet+HTML.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,11 @@
7676
*/
7777
+ (NSCharacterSet *)cssLengthUnitCharacterSet;
7878

79+
/**
80+
Characterset of ASCII Characters
81+
@returns An NSCharacterSet
82+
*/
83+
84+
+ (NSCharacterSet *)ASCIICharacterSet;
85+
7986
@end

Core/Source/NSCharacterSet+HTML.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
static NSCharacterSet *_cssStyleAttributeNameCharacterSet = nil;
1818
static NSCharacterSet *_cssLengthValueCharacterSet = nil;
1919
static NSCharacterSet *_cssLengthUnitCharacterSet = nil;
20-
20+
static NSCharacterSet *_asciiCharacterSet = nil;
2121

2222

2323
@implementation NSCharacterSet (HTML)
@@ -136,4 +136,17 @@ + (NSCharacterSet *)cssLengthUnitCharacterSet
136136
return _cssLengthUnitCharacterSet;
137137
}
138138

139+
+ (NSCharacterSet *)ASCIICharacterSet
140+
{
141+
static dispatch_once_t predicate;
142+
143+
dispatch_once(&predicate, ^{
144+
NSMutableCharacterSet *tmpSet = [NSMutableCharacterSet new];
145+
[tmpSet addCharactersInRange:NSMakeRange(32, 96)];
146+
_asciiCharacterSet = [tmpSet copy];
147+
});
148+
149+
return _asciiCharacterSet;
150+
}
151+
139152
@end

Core/Source/NSScanner+HTML.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ - (BOOL)scanCSSAttribute:(NSString * __autoreleasing*)name value:(id __autorelea
5757
NSMutableArray *results = [NSMutableArray array];
5858
BOOL nextIterationAddsNewEntry = YES;
5959

60-
while (![self isAtEnd] && ![self scanString:@";" intoString:NULL])
60+
while (![self isAtEnd] && ![self scanString:@";" intoString:NULL] && ![self scanString:@"'';" intoString:NULL] && ![self scanString:@"\"\";" intoString:NULL])
6161
{
6262
// skip whitespace
6363
[self scanCharactersFromSet:whiteCharacterSet intoString:NULL];

Core/Source/NSString+HTML.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,9 @@
7979
*/
8080
- (NSString *)stringByAddingAppleConvertedSpace;
8181

82+
/**
83+
Percent-encodes all characters outside the normal ASCII range
84+
*/
85+
- (NSString *)stringByEncodingNonASCIICharacters;
86+
8287
@end

Core/Source/NSString+HTML.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "NSString+HTML.h"
1010
#import "NSCharacterSet+HTML.h"
1111
#import "DTCoreTextConstants.h"
12+
#import <DTFoundation/NSString+DTURLEncoding.h>
1213

1314
static NSDictionary *entityLookup = nil;
1415
static NSDictionary *entityReverseLookup = nil;
@@ -798,4 +799,13 @@ - (NSString *)stringByAddingAppleConvertedSpace
798799
return output;
799800
}
800801

802+
- (NSString *)stringByEncodingNonASCIICharacters
803+
{
804+
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0
805+
return [self stringByURLEncoding];
806+
#else
807+
return [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet ASCIICharacterSet]];
808+
#endif
809+
}
810+
801811
@end

DTCoreText.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'DTCoreText'
3-
spec.version = '1.6.23'
3+
spec.version = '1.6.24'
44
spec.platforms = {:ios => '4.3', :tvos => '9.0' }
55
spec.license = 'BSD'
66
spec.source = { :git => 'https://github.com/Cocoanetics/DTCoreText.git', :tag => spec.version.to_s }

DTCoreText.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
A76E5B4912DD9AF500711782 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A76E5B4812DD9AF500711782 /* QuartzCore.framework */; };
217217
A776DBE81716A8EE00E71F36 /* NSStringParagraphTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A776DBE71716A8EE00E71F36 /* NSStringParagraphTest.m */; };
218218
A77A3E421779BF04000B290B /* NSMutableAttributedStringHTMLTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A77A3E411779BF03000B290B /* NSMutableAttributedStringHTMLTest.m */; };
219+
A786FBAB247BFC1D00890B3D /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A786FB91247BFC1D00890B3D /* WebKit.framework */; };
219220
A788CA3A14863EF100E1AFD9 /* Alignment.html in Resources */ = {isa = PBXBuildFile; fileRef = A788CA1B14863EF100E1AFD9 /* Alignment.html */; };
220221
A788CA3B14863EF100E1AFD9 /* APOD.html in Resources */ = {isa = PBXBuildFile; fileRef = A788CA1C14863EF100E1AFD9 /* APOD.html */; };
221222
A788CA3C14863EF100E1AFD9 /* ArabicTest.html in Resources */ = {isa = PBXBuildFile; fileRef = A788CA1D14863EF100E1AFD9 /* ArabicTest.html */; };
@@ -882,6 +883,7 @@
882883
A77A3E411779BF03000B290B /* NSMutableAttributedStringHTMLTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSMutableAttributedStringHTMLTest.m; sourceTree = "<group>"; };
883884
A783CE6717D11D0100C84C28 /* CSSOOMCrash.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = CSSOOMCrash.plist; sourceTree = "<group>"; };
884885
A785701C17FAA69D0080AB0A /* DTFoundation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = DTFoundation.xcodeproj; path = DTFoundation/DTFoundation.xcodeproj; sourceTree = "<group>"; };
886+
A786FB91247BFC1D00890B3D /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.5.sdk/System/Library/Frameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; };
885887
A788C91014863E8700E1AFD9 /* DTAttributedTextCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DTAttributedTextCell.h; sourceTree = "<group>"; };
886888
A788C91114863E8700E1AFD9 /* DTAttributedTextCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = DTAttributedTextCell.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
887889
A788C91214863E8700E1AFD9 /* DTAttributedTextContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DTAttributedTextContentView.h; sourceTree = "<group>"; };
@@ -1082,6 +1084,7 @@
10821084
isa = PBXFrameworksBuildPhase;
10831085
buildActionMask = 2147483647;
10841086
files = (
1087+
A786FBAB247BFC1D00890B3D /* WebKit.framework in Frameworks */,
10851088
A7949A0014C6256B00A8CCDE /* libxml2.dylib in Frameworks */,
10861089
A75C6C72141798CE00AEE350 /* MobileCoreServices.framework in Frameworks */,
10871090
A7D29D661CB68D470068F043 /* DTCoreText.framework in Frameworks */,
@@ -1194,6 +1197,7 @@
11941197
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
11951198
isa = PBXGroup;
11961199
children = (
1200+
A786FB91247BFC1D00890B3D /* WebKit.framework */,
11971201
A74A7AAC1B617250004163BE /* QuartzCore.framework */,
11981202
A74A7AAA1B617227004163BE /* CoreGraphics.framework */,
11991203
A74A7AA81B617222004163BE /* UIKit.framework */,
@@ -3258,7 +3262,7 @@
32583262
CLANG_WARN_UNREACHABLE_CODE = YES;
32593263
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
32603264
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
3261-
CURRENT_PROJECT_VERSION = 1.6.23;
3265+
CURRENT_PROJECT_VERSION = 1.6.24;
32623266
ENABLE_STRICT_OBJC_MSGSEND = YES;
32633267
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
32643268
GCC_C_LANGUAGE_STANDARD = c99;
@@ -3400,7 +3404,7 @@
34003404
CLANG_WARN_UNREACHABLE_CODE = YES;
34013405
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
34023406
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
3403-
CURRENT_PROJECT_VERSION = 1.6.23;
3407+
CURRENT_PROJECT_VERSION = 1.6.24;
34043408
ENABLE_STRICT_OBJC_MSGSEND = YES;
34053409
ENABLE_TESTABILITY = YES;
34063410
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
@@ -3456,7 +3460,7 @@
34563460
CLANG_WARN_UNREACHABLE_CODE = YES;
34573461
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
34583462
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
3459-
CURRENT_PROJECT_VERSION = 1.6.23;
3463+
CURRENT_PROJECT_VERSION = 1.6.24;
34603464
ENABLE_STRICT_OBJC_MSGSEND = YES;
34613465
FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks";
34623466
GCC_C_LANGUAGE_STANDARD = c99;

0 commit comments

Comments
 (0)