From 7b028a2819eb07805382c4e26ba1c87f67777f24 Mon Sep 17 00:00:00 2001 From: iska Date: Fri, 13 Oct 2017 22:47:53 +0200 Subject: [PATCH 1/8] Enable warnings for documentation comments and fix present errors --- HTMLKit.xcodeproj/project.pbxproj | 8 ++++++++ Sources/include/CSSPseudoFunctionSelector.h | 2 +- Sources/include/CSSSelector.h | 2 +- Sources/include/CSSSelectors.h | 2 +- Sources/include/HTMLCommentToken.h | 2 +- Sources/include/HTMLElement.h | 10 +++++----- Sources/include/HTMLInputStreamReader.h | 3 ++- Sources/include/HTMLNode.h | 4 ++-- Sources/include/HTMLRange.h | 8 ++++---- Sources/include/HTMLStackOfOpenElements.h | 2 +- Sources/include/HTMLTreeWalker.h | 1 - 11 files changed, 26 insertions(+), 18 deletions(-) diff --git a/HTMLKit.xcodeproj/project.pbxproj b/HTMLKit.xcodeproj/project.pbxproj index 723b0a5..3c66070 100644 --- a/HTMLKit.xcodeproj/project.pbxproj +++ b/HTMLKit.xcodeproj/project.pbxproj @@ -2118,6 +2118,7 @@ 625A14D519C7829400AD0C32 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -2143,6 +2144,7 @@ 625A14D619C7829400AD0C32 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -2218,6 +2220,7 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNREACHABLE_CODE = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; CURRENT_PROJECT_VERSION = 1; @@ -2253,6 +2256,7 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ANALYZER_NONNULL = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNREACHABLE_CODE = YES; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; COPY_PHASE_STRIP = NO; @@ -2288,6 +2292,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_NONNULL = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=*]" = "iPhone Developer"; @@ -2323,6 +2328,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ANALYZER_NONNULL = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=*]" = "iPhone Developer"; @@ -2399,6 +2405,7 @@ 62ECBF5F1C0B6C7600AF847B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; @@ -2435,6 +2442,7 @@ 62ECBF601C0B6C7600AF847B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; diff --git a/Sources/include/CSSPseudoFunctionSelector.h b/Sources/include/CSSPseudoFunctionSelector.h index f995d5c..9bd36d2 100644 --- a/Sources/include/CSSPseudoFunctionSelector.h +++ b/Sources/include/CSSPseudoFunctionSelector.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN /** Initializes and returns a CSS has-descendant selector, e.g. 'div:has(p)' - @discussion 'div:has(p)' matches all
elements which have a descendant

element. + @discussion 'div:has(p)' matches all <div> elements which have a descendant <p> element. @param selector The selector matching a descendant element. @return A new instance of the has-descendant selector. diff --git a/Sources/include/CSSSelector.h b/Sources/include/CSSSelector.h index 9fd8007..474b8a3 100644 --- a/Sources/include/CSSSelector.h +++ b/Sources/include/CSSSelector.h @@ -76,7 +76,7 @@ extern NSString * _Nonnull NSStringFromNthExpression(CSSNthExpression expression @param string The selector string which will be parsed. @return A new instance of a parsed CSS Selector, `nil` if the string is not a valid selector string. */ -+ (nullable instancetype)selectorWithString:(NSString *)stirng; ++ (nullable instancetype)selectorWithString:(NSString *)string; /** Implementations should override this method to provide the selector-sprecific logic for matching elements. diff --git a/Sources/include/CSSSelectors.h b/Sources/include/CSSSelectors.h index bd8acd9..c6e8a1f 100644 --- a/Sources/include/CSSSelectors.h +++ b/Sources/include/CSSSelectors.h @@ -225,7 +225,7 @@ extern CSSSelector * not(CSSSelector *selector); /** CSS has-descendant selector, e.g. 'div:has(p)' - @discussion 'div:has(p)' matches all

elements which have a descendant

element. + @discussion 'div:has(p)' matches all <div> elements which have a descendant <p> element. @param selector The selector matching a descendant element. @return A has-descendant selector. diff --git a/Sources/include/HTMLCommentToken.h b/Sources/include/HTMLCommentToken.h index a42172a..5c43f1e 100644 --- a/Sources/include/HTMLCommentToken.h +++ b/Sources/include/HTMLCommentToken.h @@ -24,7 +24,7 @@ /** Initializes a new comment token. - @param string The string with which to initialize the token. + @param data The string with which to initialize the token. @return A new instance of a comment token. */ - (instancetype)initWithData:(NSString *)data; diff --git a/Sources/include/HTMLElement.h b/Sources/include/HTMLElement.h index 524921a..2d0b3f5 100644 --- a/Sources/include/HTMLElement.h +++ b/Sources/include/HTMLElement.h @@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN /** Initializes a new HTML element with the given tag name. - @param tagname The tag name. + @param tagName The tag name. @return A new HTML element. */ - (instancetype)initWithTagName:(NSString *)tagName; @@ -71,7 +71,7 @@ NS_ASSUME_NONNULL_BEGIN /** Initializes a new HTML element with the given tag name and attributes. - @param tagname The tag name. + @param tagName The tag name. @param attributes The attributes. @return A new HTML element. */ @@ -80,8 +80,8 @@ NS_ASSUME_NONNULL_BEGIN /** Initializes a new HTML element with the given tag name, namespace, and attributes. - @param tagname The tag name. - @param namespace The namespace. + @param tagName The tag name. + @param htmlNamespace The HTML namespace. @param attributes The attributes. @return A new HTML element. */ @@ -107,7 +107,7 @@ NS_ASSUME_NONNULL_BEGIN Set the value of the attribute with the given name. @param value The value to set. - @param name The attribute's name. + @param attribute The attribute's name. */ - (void)setObject:(NSString *)value forKeyedSubscript:(NSString *)attribute; diff --git a/Sources/include/HTMLInputStreamReader.h b/Sources/include/HTMLInputStreamReader.h index 01d3a6f..d018e00 100644 --- a/Sources/include/HTMLInputStreamReader.h +++ b/Sources/include/HTMLInputStreamReader.h @@ -15,7 +15,8 @@ /** Typedef for the error callback block. - @param reason The string describing the reason of the reported error. + @param code The standarized error-code + @param details The string describing the reason of the reported error. */ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *code, NSString *details); diff --git a/Sources/include/HTMLNode.h b/Sources/include/HTMLNode.h index c9ca332..2631fa7 100644 --- a/Sources/include/HTMLNode.h +++ b/Sources/include/HTMLNode.h @@ -232,7 +232,7 @@ typedef NS_OPTIONS(unsigned short, HTMLDocumentPosition) /** Returns the index of the given child element in the set of child nodes. - @param node The element. + @param element The element. @return The index of the given element in the children set. */ - (NSUInteger)indexOfChildElement:(HTMLElement *)element; @@ -248,7 +248,7 @@ typedef NS_OPTIONS(unsigned short, HTMLDocumentPosition) /** Prepends the given array of nodes to the set of child nodes. - @param node The nodes to prepend. + @param nodes The nodes to prepend. */ - (void)prependNodes:(NSArray *)nodes; diff --git a/Sources/include/HTMLRange.h b/Sources/include/HTMLRange.h index 282f3bc..3cc4950 100644 --- a/Sources/include/HTMLRange.h +++ b/Sources/include/HTMLRange.h @@ -113,16 +113,16 @@ typedef NS_ENUM(unsigned short, HTMLRangeComparisonMethod) /** Sets the start boundary. - @param startNode The new node of the start boundary. - @param startOffset The new offset of the start boundary. + @param node The new node of the start boundary. + @param offset The new offset of the start boundary. */ - (void)setStartNode:(HTMLNode *)node startOffset:(NSUInteger)offset; /** Sets the end boundary. - @param startNode The new node of the end boundary. - @param startOffset The new offset of the end boundary. + @param node The new node of the end boundary. + @param offset The new offset of the end boundary. */ - (void)setEndNode:(HTMLNode *)node endOffset:(NSUInteger)offset; diff --git a/Sources/include/HTMLStackOfOpenElements.h b/Sources/include/HTMLStackOfOpenElements.h index a7f0e0e..d379841 100644 --- a/Sources/include/HTMLStackOfOpenElements.h +++ b/Sources/include/HTMLStackOfOpenElements.h @@ -79,7 +79,7 @@ /** Checks whether an element with the given tag name is in the stack. - @param tagname The element's tag name. + @param tagName The element's tag name. @return `YES` if such an element is in the stack, `NO` otherwise. */ - (BOOL)containsElementWithTagName:(NSString *)tagName; diff --git a/Sources/include/HTMLTreeWalker.h b/Sources/include/HTMLTreeWalker.h index 3b9282a..2faaca1 100644 --- a/Sources/include/HTMLTreeWalker.h +++ b/Sources/include/HTMLTreeWalker.h @@ -49,7 +49,6 @@ NS_ASSUME_NONNULL_BEGIN Initializes a new tree walker with no filter and HTMLNodeFilterShowAll show options. @param node The root node. - @param filter The node filter to use. @return A new instance of a tree walker. */ - (instancetype)initWithNode:(HTMLNode *)node; From 84960e71ee6c796f367d3d54b11b5a7d34bd4ae0 Mon Sep 17 00:00:00 2001 From: iska Date: Fri, 13 Oct 2017 22:51:17 +0200 Subject: [PATCH 2/8] Enable warnings for missing function prototypes and fix present error --- HTMLKit.xcodeproj/project.pbxproj | 16 ++++++++++++++++ Sources/CSSNthExpressionSelector.m | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/HTMLKit.xcodeproj/project.pbxproj b/HTMLKit.xcodeproj/project.pbxproj index 3c66070..551319f 100644 --- a/HTMLKit.xcodeproj/project.pbxproj +++ b/HTMLKit.xcodeproj/project.pbxproj @@ -2128,8 +2128,10 @@ FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; INSTALL_PATH = "@rpath"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2154,8 +2156,10 @@ FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; INSTALL_PATH = "@rpath"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2232,7 +2236,9 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2268,7 +2274,9 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2306,7 +2314,9 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2342,7 +2352,9 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -2418,8 +2430,10 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_INHIBIT_ALL_WARNINGS = NO; GCC_WARN_PEDANTIC = NO; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; @@ -2455,8 +2469,10 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_PREFIX_HEADER = ""; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_INHIBIT_ALL_WARNINGS = NO; GCC_WARN_PEDANTIC = NO; INFOPLIST_FILE = "Sources/HTMLKit-Info.plist"; diff --git a/Sources/CSSNthExpressionSelector.m b/Sources/CSSNthExpressionSelector.m index 9f74f8b..d93f918 100644 --- a/Sources/CSSNthExpressionSelector.m +++ b/Sources/CSSNthExpressionSelector.m @@ -38,7 +38,7 @@ #pragma mark - Implementation -NSInteger computeIndex(NSEnumerator *enumerator, HTMLElement *element) +NS_INLINE NSInteger computeIndex(NSEnumerator *enumerator, HTMLElement *element) { NSInteger index = 0; for (HTMLNode *node in enumerator) { From 135715b606537ad92c788544f13ef29fe98ddcb9 Mon Sep 17 00:00:00 2001 From: iska Date: Mon, 6 Nov 2017 21:55:41 +0100 Subject: [PATCH 3/8] Fix HTMLText serialization Fixes #16 --- HTMLKit.xcodeproj/project.pbxproj | 8 +++++ Sources/HTMLText.m | 9 +++-- Tests/HTMLKitTests/HTMLSerializationTests.m | 38 +++++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 Tests/HTMLKitTests/HTMLSerializationTests.m diff --git a/HTMLKit.xcodeproj/project.pbxproj b/HTMLKit.xcodeproj/project.pbxproj index 551319f..6320f07 100644 --- a/HTMLKit.xcodeproj/project.pbxproj +++ b/HTMLKit.xcodeproj/project.pbxproj @@ -306,6 +306,9 @@ 62857D8F1D39A47F008DC254 /* CSSCombinatorSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = 62FA04E11BCC360D009ABF98 /* CSSCombinatorSelector.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62857D901D39A47F008DC254 /* CSSCompoundSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = 620C87791BD44CBE00FB3EEE /* CSSCompoundSelector.h */; settings = {ATTRIBUTES = (Public, ); }; }; 628AF6301BC99A6C00496128 /* CSSNthExpressionsParserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 628AF62E1BC99A6C00496128 /* CSSNthExpressionsParserTests.m */; }; + 62A95A4D1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */; }; + 62A95A4E1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */; }; + 62A95A4F1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */; }; 62D8345A19FB1AC4009205A9 /* HTML5LibTokenizerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 62D8345819FB1AC4009205A9 /* HTML5LibTokenizerTest.m */; }; 62D91C231DE218A500BEFADE /* HTMLRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 62D91C211DE218A500BEFADE /* HTMLRange.h */; settings = {ATTRIBUTES = (Public, ); }; }; 62D91C241DE218A500BEFADE /* HTMLRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 62D91C211DE218A500BEFADE /* HTMLRange.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -703,6 +706,7 @@ 628AF63C1BC9D6FB00496128 /* CSSStructuralPseudoSelectors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSStructuralPseudoSelectors.h; path = include/CSSStructuralPseudoSelectors.h; sourceTree = ""; }; 628AF63D1BC9D6FB00496128 /* CSSStructuralPseudoSelectors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSStructuralPseudoSelectors.m; sourceTree = ""; }; 628B7CE61A080E1000602C87 /* HTMLNamespaces.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTMLNamespaces.h; path = include/HTMLNamespaces.h; sourceTree = ""; }; + 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = HTMLSerializationTests.m; path = HTMLKitTests/HTMLSerializationTests.m; sourceTree = ""; }; 62ACB8DB1BC5C13E00E283C1 /* CSSPseudoFunctionSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSPseudoFunctionSelector.h; path = include/CSSPseudoFunctionSelector.h; sourceTree = ""; }; 62ACB8DC1BC5C13E00E283C1 /* CSSPseudoFunctionSelector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSPseudoFunctionSelector.m; sourceTree = ""; }; 62AE593319F97D880043F069 /* HTMLParseErrorToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLParseErrorToken.h; path = include/HTMLParseErrorToken.h; sourceTree = ""; }; @@ -885,6 +889,7 @@ 62EC7AE51AEEAC6F0015D3BE /* HTMLMutationAlgorithmsTests.m */, 62EC0A841E158BD80007786B /* HTMLRangeTests.m */, 62E0BA961E25456700E4D193 /* HTMLCharacterDataTests.m */, + 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */, ); name = DOM; sourceTree = ""; @@ -1761,6 +1766,7 @@ 62567F561C0CC3AE0025D458 /* HTMLDOMTokenListTests.m in Sources */, 624AC90219FBF9ED00BD3C4A /* HTMLKitTokenizerTests.m in Sources */, 624B9FB31AE0313300646C4C /* HTMLStringCategoryTests.m in Sources */, + 62A95A4D1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */, 623916C81AC7209E0066B4FE /* HTMLNodeIteratorTests.m in Sources */, 62D8345A19FB1AC4009205A9 /* HTML5LibTokenizerTest.m in Sources */, 6239755F1AC364BB007E26F1 /* HTML5LibTreeConstructionTest.m in Sources */, @@ -1903,6 +1909,7 @@ 62857D401D39A345008DC254 /* CSSAttributeSelectorTests.m in Sources */, 62857D311D39A33C008DC254 /* HTML5LibTreeConstructionTest.m in Sources */, 62857D391D39A342008DC254 /* HTMLOrderedDictionaryTests.m in Sources */, + 62A95A4F1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */, 62857D411D39A345008DC254 /* CSSNThExpressionSelectorTests.m in Sources */, 62857D381D39A342008DC254 /* HTMLStringCategoryTests.m in Sources */, 62857D331D39A33C008DC254 /* HTMLKitParserPerformance.m in Sources */, @@ -1990,6 +1997,7 @@ 62567F571C0CC3AE0025D458 /* HTMLDOMTokenListTests.m in Sources */, 62ECBFD41C0B6E2E00AF847B /* HTMLStringCategoryTests.m in Sources */, 62ECBFD51C0B6E2E00AF847B /* HTMLOrderedDictionaryTests.m in Sources */, + 62A95A4E1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */, 62ECBFD61C0B6E2E00AF847B /* CSSSelectorTest.m in Sources */, 62ECBFD71C0B6E2E00AF847B /* CSSSelectorParserTests.m in Sources */, 62ECBFD81C0B6E2E00AF847B /* CSSNthExpressionsParserTests.m in Sources */, diff --git a/Sources/HTMLText.m b/Sources/HTMLText.m index 76e94d3..bea9c9b 100644 --- a/Sources/HTMLText.m +++ b/Sources/HTMLText.m @@ -74,12 +74,11 @@ - (NSString *)outerHTML @"plaintext", @"noscript", nil]) { return self.data; } else { - NSRange range = NSMakeRange(0, self.data.length); NSMutableString *escaped = [self.data mutableCopy]; - [escaped replaceOccurrencesOfString:@"&" withString:@"&" options:0 range:range]; - [escaped replaceOccurrencesOfString:@"\00A0" withString:@" " options:0 range:range]; - [escaped replaceOccurrencesOfString:@"<" withString:@"<" options:0 range:range]; - [escaped replaceOccurrencesOfString:@">" withString:@">" options:0 range:range]; + [escaped replaceOccurrencesOfString:@"&" withString:@"&" options:0 range:NSMakeRange(0, escaped.length)]; + [escaped replaceOccurrencesOfString:@"\00A0" withString:@" " options:0 range:NSMakeRange(0, escaped.length)]; + [escaped replaceOccurrencesOfString:@"<" withString:@"<" options:0 range:NSMakeRange(0, escaped.length)]; + [escaped replaceOccurrencesOfString:@">" withString:@">" options:0 range:NSMakeRange(0, escaped.length)]; return escaped; } } diff --git a/Tests/HTMLKitTests/HTMLSerializationTests.m b/Tests/HTMLKitTests/HTMLSerializationTests.m new file mode 100644 index 0000000..3901bc9 --- /dev/null +++ b/Tests/HTMLKitTests/HTMLSerializationTests.m @@ -0,0 +1,38 @@ +// +// HTMLSerializationTests.m +// HTMLKit +// +// Created by Iska on 06.11.17. +// Copyright © 2017 BrainCookie. All rights reserved. +// + +#import +#import "HTMLDOM.h" + +@interface HTMLSerializationTests : XCTestCase + +@end + +@implementation HTMLSerializationTests + +- (void)setUp { + [super setUp]; +} + +- (void)tearDown { + [super tearDown]; +} + +#pragma mark - Bug Fixes + +- (void)testBugFix_Issue_16 +{ + NSString *html = @"

<test>
"; + HTMLDocument *document = [HTMLDocument documentWithString:html]; + + XCTAssertEqualObjects(document.body.outerHTML, html); +} + +} + +@end From 2dfdeb22ca41a1f2cb5d1b80d15a122b9b79667a Mon Sep 17 00:00:00 2001 From: iska Date: Mon, 6 Nov 2017 21:58:08 +0100 Subject: [PATCH 4/8] Fix HTMLElement attribute value serialization Fixes #17 --- Sources/HTMLElement.m | 7 +++---- Tests/HTMLKitTests/HTMLSerializationTests.m | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Sources/HTMLElement.m b/Sources/HTMLElement.m index f36bc02..7904e33 100644 --- a/Sources/HTMLElement.m +++ b/Sources/HTMLElement.m @@ -157,11 +157,10 @@ - (NSString *)outerHTML [result appendFormat:@"<%@", self.tagName]; [self.attributes enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, BOOL *stop) { - NSRange range = NSMakeRange(0, value.length); NSMutableString *escaped = [value mutableCopy]; - [escaped replaceOccurrencesOfString:@"&" withString:@"&" options:0 range:range]; - [escaped replaceOccurrencesOfString:@"\00A0" withString:@" " options:0 range:range]; - [escaped replaceOccurrencesOfString:@"\"" withString:@""" options:0 range:range]; + [escaped replaceOccurrencesOfString:@"&" withString:@"&" options:0 range:NSMakeRange(0, escaped.length)]; + [escaped replaceOccurrencesOfString:@"0x00A0" withString:@" " options:0 range:NSMakeRange(0, escaped.length)]; + [escaped replaceOccurrencesOfString:@"\"" withString:@""" options:0 range:NSMakeRange(0, escaped.length)]; [result appendFormat:@" %@=\"%@\"", key, escaped]; }]; diff --git a/Tests/HTMLKitTests/HTMLSerializationTests.m b/Tests/HTMLKitTests/HTMLSerializationTests.m index 3901bc9..d35087f 100644 --- a/Tests/HTMLKitTests/HTMLSerializationTests.m +++ b/Tests/HTMLKitTests/HTMLSerializationTests.m @@ -33,6 +33,12 @@ - (void)testBugFix_Issue_16 XCTAssertEqualObjects(document.body.outerHTML, html); } +- (void)testBugFix_Issue_17 +{ + NSString *html = @""; + HTMLDocument *document = [HTMLDocument documentWithString:html]; + + XCTAssertEqualObjects(document.body.outerHTML, @""); } @end From 5302c16600dba1372eb2abea203ddca3e0454e86 Mon Sep 17 00:00:00 2001 From: iska Date: Mon, 6 Nov 2017 22:04:18 +0100 Subject: [PATCH 5/8] Add Changelog entry for HTMLKit 2.1.2 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f561ccb..89699fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## [2.1.2](https://github.com/iabudiab/HTMLKit/releases/tag/2.1.2) + +Released on 2017.11.6 + +### Fixes + +- `HTMLText` serialization (issue #16) +- `HTMLElement` attribute value serialization (issue #17) + + ## [2.1.1](https://github.com/iabudiab/HTMLKit/releases/tag/2.1.1) Released on 2017.10.13 From fb7ea25b1fdb0d575cfc248dc19c69ea3fd98a44 Mon Sep 17 00:00:00 2001 From: iska Date: Mon, 6 Nov 2017 22:04:29 +0100 Subject: [PATCH 6/8] Update jazzy.yaml for 2.1.2 --- .jazzy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jazzy.yaml b/.jazzy.yaml index 3d6ff49..245f1dc 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -1,5 +1,5 @@ module: HTMLKit -module_version: 2.1.1 +module_version: 2.1.2 author: Iskandar Abudiab author_url: https://twitter.com/iabudiab github_url: https://github.com/iabudiab/HTMLKit From 820b3ef0917c54c094092a386c13271ca066b045 Mon Sep 17 00:00:00 2001 From: iska Date: Mon, 6 Nov 2017 22:04:38 +0100 Subject: [PATCH 7/8] Update podspec for 2.1.2 --- HTMLKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HTMLKit.podspec b/HTMLKit.podspec index 340d22c..555d09f 100644 --- a/HTMLKit.podspec +++ b/HTMLKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "HTMLKit" - s.version = "2.1.1" + s.version = "2.1.2" s.summary = "HTMLKit, an Objective-C framework for your everyday HTML needs." s.license = "MIT" s.homepage = "https://github.com/iabudiab/HTMLKit" From 16ed846e653af7fe06717c34703ce17051b9fe5d Mon Sep 17 00:00:00 2001 From: iska Date: Mon, 6 Nov 2017 22:04:57 +0100 Subject: [PATCH 8/8] Bump HTMLKit version to 2.1.2 --- Sources/HTMLKit-Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/HTMLKit-Info.plist b/Sources/HTMLKit-Info.plist index 2a70e8c..fbe7ffd 100644 --- a/Sources/HTMLKit-Info.plist +++ b/Sources/HTMLKit-Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.1.1 + 2.1.2 CFBundleSignature ???? CFBundleVersion