Skip to content

Commit d756fc4

Browse files
committed
Merge branch 'release/2.1.5'
2 parents bf0d856 + 7c23351 commit d756fc4

File tree

11 files changed

+90
-35
lines changed

11 files changed

+90
-35
lines changed

.jazzy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module: HTMLKit
2-
module_version: 2.1.4
2+
module_version: 2.1.5
33
author: Iskandar Abudiab
44
author_url: https://twitter.com/iabudiab
55
github_url: https://github.com/iabudiab/HTMLKit

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## [2.1.5](https://github.com/iabudiab/HTMLKit/releases/tag/2.1.5)
4+
5+
Released on 2018.07.16
6+
7+
### Fixes
8+
9+
- Parser would handle foreign attributes incorrectly (issue #30)
10+
11+
312
## [2.1.4](https://github.com/iabudiab/HTMLKit/releases/tag/2.1.4)
413

514
Released on 2018.05.01

HTMLKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "HTMLKit"
3-
s.version = "2.1.4"
3+
s.version = "2.1.5"
44
s.summary = "HTMLKit, an Objective-C framework for your everyday HTML needs."
55
s.license = "MIT"
66
s.homepage = "https://github.com/iabudiab/HTMLKit"

HTMLKit.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@
312312
62A95A4D1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */; };
313313
62A95A4E1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */; };
314314
62A95A4F1FB0FBFC0009FF26 /* HTMLSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62A95A4C1FB0FBFC0009FF26 /* HTMLSerializationTests.m */; };
315+
62C82E0D20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C82E0C20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m */; };
316+
62C82E0E20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C82E0C20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m */; };
317+
62C82E0F20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C82E0C20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m */; };
315318
62D8345A19FB1AC4009205A9 /* HTML5LibTokenizerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 62D8345819FB1AC4009205A9 /* HTML5LibTokenizerTest.m */; };
316319
62D91C231DE218A500BEFADE /* HTMLRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 62D91C211DE218A500BEFADE /* HTMLRange.h */; settings = {ATTRIBUTES = (Public, ); }; };
317320
62D91C241DE218A500BEFADE /* HTMLRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 62D91C211DE218A500BEFADE /* HTMLRange.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -723,6 +726,7 @@
723726
62AE594319F992F30043F069 /* HTMLCommentToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLCommentToken.m; sourceTree = "<group>"; };
724727
62AE594719F9948A0043F069 /* HTMLCharacterToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLCharacterToken.h; path = include/HTMLCharacterToken.h; sourceTree = "<group>"; };
725728
62AE594819F9948A0043F069 /* HTMLCharacterToken.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTMLCharacterToken.m; sourceTree = "<group>"; };
729+
62C82E0C20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = HTMLKitParserIssuesTests.m; path = HTMLKitTests/HTMLKitParserIssuesTests.m; sourceTree = "<group>"; };
726730
62D8345719FB1AC4009205A9 /* HTML5LibTokenizerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTML5LibTokenizerTest.h; path = HTMLKitTests/HTML5LibTokenizerTest.h; sourceTree = "<group>"; };
727731
62D8345819FB1AC4009205A9 /* HTML5LibTokenizerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HTML5LibTokenizerTest.m; path = HTMLKitTests/HTML5LibTokenizerTest.m; sourceTree = "<group>"; };
728732
62D91C211DE218A500BEFADE /* HTMLRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLRange.h; path = include/HTMLRange.h; sourceTree = "<group>"; };
@@ -993,6 +997,7 @@
993997
625EE45A1CBB171300F2CC8E /* HTMLKitTestUtil.m */,
994998
6236738C1AC0CD2400FF89B3 /* Tokenizer */,
995999
623975581AC362A5007E26F1 /* Tree Construction */,
1000+
62C82E0B20FD2FCB008497A8 /* Parser */,
9961001
624B9FB71AE072CB00646C4C /* DOM */,
9971002
624B9FB81AE072D500646C4C /* Categories */,
9981003
624E1A2D1B1D1C8A00E66AAC /* Structures */,
@@ -1097,6 +1102,14 @@
10971102
name = Tokenizing;
10981103
sourceTree = "<group>";
10991104
};
1105+
62C82E0B20FD2FCB008497A8 /* Parser */ = {
1106+
isa = PBXGroup;
1107+
children = (
1108+
62C82E0C20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m */,
1109+
);
1110+
name = Parser;
1111+
sourceTree = "<group>";
1112+
};
11001113
62ECBEDF1C0B671000AF847B /* Parsing */ = {
11011114
isa = PBXGroup;
11021115
children = (
@@ -1758,6 +1771,7 @@
17581771
620AB7B12087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */,
17591772
62E0BA971E25456700E4D193 /* HTMLCharacterDataTests.m in Sources */,
17601773
6216ACFD1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m in Sources */,
1774+
62C82E0D20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m in Sources */,
17611775
62132E5A1C01F83200084175 /* CSSSelectorTest.m in Sources */,
17621776
6239755B1AC362CA007E26F1 /* HTMLKitTreeConstructionTests.m in Sources */,
17631777
62F658711BD83C8E0045F137 /* CSSNThExpressionSelectorTests.m in Sources */,
@@ -1902,6 +1916,7 @@
19021916
620AB7B32087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */,
19031917
62E0BA991E25456700E4D193 /* HTMLCharacterDataTests.m in Sources */,
19041918
62857D3B1D39A345008DC254 /* CSSSelectorTest.m in Sources */,
1919+
62C82E0F20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m in Sources */,
19051920
62857D421D39A345008DC254 /* CSSCombinatorSelectorTests.m in Sources */,
19061921
62857D3C1D39A345008DC254 /* CSSSelectorParserTests.m in Sources */,
19071922
62857D301D39A339008DC254 /* HTMLKitTokenizerPerformance.m in Sources */,
@@ -1991,6 +2006,7 @@
19912006
620AB7B22087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */,
19922007
62E0BA981E25456700E4D193 /* HTMLCharacterDataTests.m in Sources */,
19932008
6216ACFE1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m in Sources */,
2009+
62C82E0E20FD2FFD008497A8 /* HTMLKitParserIssuesTests.m in Sources */,
19942010
62ECBFCA1C0B6E2E00AF847B /* HTML5LibTokenizerTest.m in Sources */,
19952011
62ECBFCB1C0B6E2E00AF847B /* HTMLKitTokenizerTests.m in Sources */,
19962012
62ECBFCC1C0B6E2E00AF847B /* HTMLKitTokenizerPerformance.m in Sources */,

Sources/HTMLKit-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>FMWK</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>2.1.4</string>
20+
<string>2.1.5</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>

Sources/HTMLNode.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ - (HTMLElement *)previousSiblingElement
127127

128128
- (HTMLElement *)nextSiblingElement
129129
{
130-
HTMLNode *node = self.previousSibling;
130+
HTMLNode *node = self.nextSibling;
131131
while (node && node.nodeType != HTMLNodeElement) {
132132
node = node.nextSibling;
133133
}

Sources/HTMLParser.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,15 +1443,13 @@ - (void)processStartTagTokenInBody:(HTMLStartTagToken *)token
14431443
} else if ([tagName isEqualToString:@"math"]) {
14441444
[self reconstructActiveFormattingElements];
14451445
AdjustMathMLAttributes(token);
1446-
AdjustForeignAttributes(token);
14471446
[self insertForeignElementForToken:token inNamespace:HTMLNamespaceMathML];
14481447
if (token.isSelfClosing) {
14491448
[_stackOfOpenElements popCurrentNode];
14501449
}
14511450
} else if ([tagName isEqualToString:@"svg"]) {
14521451
[self reconstructActiveFormattingElements];
14531452
AdjustSVGAttributes(token);
1454-
AdjustForeignAttributes(token);
14551453
[self insertForeignElementForToken:token inNamespace:HTMLNamespaceSVG];
14561454
if (token.isSelfClosing) {
14571455
[_stackOfOpenElements popCurrentNode];
@@ -2541,7 +2539,6 @@ - (void)processTokenByApplyingRulesForParsingTokensInForeignContent:(HTMLToken *
25412539
AdjustSVGNameCase(token.asTagToken);
25422540
AdjustSVGAttributes(token.asTagToken);
25432541
}
2544-
AdjustForeignAttributes(token.asTagToken);
25452542
[self insertForeignElementForToken:token.asTagToken inNamespace:self.adjustedCurrentNode.htmlNamespace];
25462543
if (token.asTagToken.selfClosing) {
25472544
[_stackOfOpenElements popCurrentNode];

Sources/include/HTMLElementAdjustment.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,3 @@ NS_INLINE void AdjustSVGNameCase(HTMLTagToken *token)
140140
NSString *replacement = replacements[token.tagName] ?: token.tagName;
141141
token.tagName = replacement;
142142
}
143-
144-
NS_INLINE void AdjustForeignAttributes(HTMLTagToken *token)
145-
{
146-
if (token.attributes == nil) {
147-
return;
148-
}
149-
150-
NSDictionary *replacements = @{ @"xlink:actuate": @"xlink actuate",
151-
@"xlink:arcrole": @"xlink arcrole",
152-
@"xlink:href": @"xlink href",
153-
@"xlink:role": @"xlink role",
154-
@"xlink:show": @"xlink show",
155-
@"xlink:title": @"xlink title",
156-
@"xlink:type": @"xlink type",
157-
@"xml:base": @"xml base",
158-
@"xml:lang": @"xml lang",
159-
@"xml:space": @"xml space",
160-
@"xmlns": @"xmlns",
161-
@"xmlns:xlink": @"xmlns xlink"};
162-
163-
HTMLOrderedDictionary *adjusted = [HTMLOrderedDictionary new];
164-
for (id key in token.attributes) {
165-
NSString *replacement = replacements[key] ?: key;
166-
adjusted[replacement] = token.attributes[key];
167-
}
168-
token.attributes = adjusted;
169-
}
170-

Tests/HTMLKitTests/HTML5LibTreeConstructionTest.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "HTML5LibTreeConstructionTest.h"
1010
#import <XCTest/XCTest.h>
1111

12+
#import "HTMLDOM.h"
1213
#import "HTMLDocumentType.h"
1314
#import "HTMLElement.h"
1415
#import "HTMLText.h"
@@ -289,6 +290,8 @@ + (NSArray *)parseDocument:(NSArray *)parts
289290
NSRange range = [str rangeOfString:@"=" options:0];
290291

291292
NSString *key = [str substringToIndex:range.location];
293+
key = [key stringByReplacingOccurrencesOfString:@" " withString:@":"];
294+
292295
NSString *value = [str substringFromIndex:range.location + 2];
293296
value = [value substringToIndex:value.length - 1];
294297

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// HTMLKitParserTests.m
3+
// HTMLKit
4+
//
5+
// Created by Iska on 16.07.18.
6+
// Copyright © 2018 BrainCookie. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "HTMLDOM.h"
11+
12+
@interface HTMLKitParserIssuesTests : XCTestCase
13+
14+
@end
15+
16+
@implementation HTMLKitParserIssuesTests
17+
18+
#pragma mark - Bug Fixes
19+
20+
- (void)testBugFix_Issue_30 {
21+
NSString *html =
22+
@"<body>"
23+
" <svg id='draw_area' width='600' height='800' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1'>"
24+
" <image id='overlay_img' xlink:href='foo.png' width='600' height='800'/>"
25+
" </svg>"
26+
"</body>";
27+
28+
HTMLDocument* document = [HTMLDocument documentWithString:html];
29+
HTMLElement *svg = [document querySelector:@"#draw_area"];
30+
31+
XCTAssertNil(svg.attributes[@"xlink"]);
32+
XCTAssertEqualObjects(svg.attributes[@"xmlns"], @"http://www.w3.org/2000/svg");
33+
XCTAssertEqualObjects(svg.attributes[@"xmlns:xlink"], @"http://www.w3.org/1999/xlink");
34+
35+
HTMLElement *image = [document querySelector:@"#overlay_img"];
36+
37+
XCTAssertNil(image.attributes[@"xlink"]);
38+
XCTAssertNil(image.attributes[@"href"]);
39+
XCTAssertEqualObjects(image.attributes[@"xlink:href"], @"foo.png");
40+
XCTAssertEqualObjects(image.outerHTML, @"<image id=\"overlay_img\" xlink:href=\"foo.png\" width=\"600\" height=\"800\"></image>");
41+
}
42+
43+
@end

0 commit comments

Comments
 (0)