diff --git a/Sources/HTMLParser.m b/Sources/HTMLParser.m index e9603cc..5aa9cbc 100644 --- a/Sources/HTMLParser.m +++ b/Sources/HTMLParser.m @@ -1443,7 +1443,6 @@ } else if ([tagName isEqualToString:@"math"]) { [self reconstructActiveFormattingElements]; AdjustMathMLAttributes(token); - AdjustForeignAttributes(token); [self insertForeignElementForToken:token inNamespace:HTMLNamespaceMathML]; if (token.isSelfClosing) { [_stackOfOpenElements popCurrentNode]; @@ -1451,7 +1450,6 @@ } else if ([tagName isEqualToString:@"svg"]) { [self reconstructActiveFormattingElements]; AdjustSVGAttributes(token); - AdjustForeignAttributes(token); [self insertForeignElementForToken:token inNamespace:HTMLNamespaceSVG]; if (token.isSelfClosing) { [_stackOfOpenElements popCurrentNode]; @@ -2541,7 +2539,6 @@ AdjustSVGNameCase(token.asTagToken); AdjustSVGAttributes(token.asTagToken); } - AdjustForeignAttributes(token.asTagToken); [self insertForeignElementForToken:token.asTagToken inNamespace:self.adjustedCurrentNode.htmlNamespace]; if (token.asTagToken.selfClosing) { [_stackOfOpenElements popCurrentNode]; diff --git a/Sources/include/HTMLElementAdjustment.h b/Sources/include/HTMLElementAdjustment.h index 17b1864..907fa7e 100644 --- a/Sources/include/HTMLElementAdjustment.h +++ b/Sources/include/HTMLElementAdjustment.h @@ -140,31 +140,3 @@ NS_INLINE void AdjustSVGNameCase(HTMLTagToken *token) NSString *replacement = replacements[token.tagName] ?: token.tagName; token.tagName = replacement; } - -NS_INLINE void AdjustForeignAttributes(HTMLTagToken *token) -{ - if (token.attributes == nil) { - return; - } - - NSDictionary *replacements = @{ @"xlink:actuate": @"xlink actuate", - @"xlink:arcrole": @"xlink arcrole", - @"xlink:href": @"xlink href", - @"xlink:role": @"xlink role", - @"xlink:show": @"xlink show", - @"xlink:title": @"xlink title", - @"xlink:type": @"xlink type", - @"xml:base": @"xml base", - @"xml:lang": @"xml lang", - @"xml:space": @"xml space", - @"xmlns": @"xmlns", - @"xmlns:xlink": @"xmlns xlink"}; - - HTMLOrderedDictionary *adjusted = [HTMLOrderedDictionary new]; - for (id key in token.attributes) { - NSString *replacement = replacements[key] ?: key; - adjusted[replacement] = token.attributes[key]; - } - token.attributes = adjusted; -} - diff --git a/Tests/HTMLKitTests/HTML5LibTreeConstructionTest.m b/Tests/HTMLKitTests/HTML5LibTreeConstructionTest.m index 3b08d2c..2e9231b 100644 --- a/Tests/HTMLKitTests/HTML5LibTreeConstructionTest.m +++ b/Tests/HTMLKitTests/HTML5LibTreeConstructionTest.m @@ -9,6 +9,7 @@ #import "HTML5LibTreeConstructionTest.h" #import +#import "HTMLDOM.h" #import "HTMLDocumentType.h" #import "HTMLElement.h" #import "HTMLText.h" @@ -289,6 +290,8 @@ NS_INLINE NSArray * parseAttribute(NSString *str) NSRange range = [str rangeOfString:@"=" options:0]; NSString *key = [str substringToIndex:range.location]; + key = [key stringByReplacingOccurrencesOfString:@" " withString:@":"]; + NSString *value = [str substringFromIndex:range.location + 2]; value = [value substringToIndex:value.length - 1];