Add implementation for Character Token case in in-body insertion mode
https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
This commit is contained in:
@@ -789,7 +789,30 @@
|
||||
|
||||
- (void)HTMLInsertionModeInBody:(HTMLToken *)token
|
||||
{
|
||||
switch (token.type) {
|
||||
case HTMLTokenTypeCharacter:
|
||||
{
|
||||
NSMutableString *charactes = [token.asCharacterToken.characters mutableCopy];
|
||||
NSUInteger nullCount = [charactes replaceOccurrencesOfString:@"\0"
|
||||
withString:@""
|
||||
options:NSLiteralSearch
|
||||
range:NSMakeRange(0, charactes.length)];
|
||||
for (int i = 0; i < nullCount; i++) {
|
||||
[self emitParseError:@"Unexpected Character (0x0000) in <body>"];
|
||||
}
|
||||
|
||||
if (charactes.length > 0) {
|
||||
[self reconstructActiveFormattingElements];
|
||||
[self insertCharacters:charactes];
|
||||
if ([charactes containsHTMLWhitespace]) {
|
||||
_framesetOkFlag = NO;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)HTMLInsertionModeText:(HTMLToken *)token
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
- (BOOL)isEqualToAny:(NSString *)first, ... NS_REQUIRES_NIL_TERMINATION;
|
||||
- (BOOL)isHTMLWhitespaceString;
|
||||
- (BOOL)containsHTMLWhitespace;
|
||||
- (NSUInteger)leadingWhitespaceLength;
|
||||
|
||||
@end
|
||||
|
||||
@@ -34,6 +34,12 @@ NS_INLINE BOOL isHtmlWhitespaceChar(char c)
|
||||
return [self rangeOfCharacterFromSet:set].location == NSNotFound;
|
||||
}
|
||||
|
||||
- (BOOL)containsHTMLWhitespace
|
||||
{
|
||||
NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@" \t\n\f\r"];
|
||||
return [self rangeOfCharacterFromSet:set].location != NSNotFound;
|
||||
}
|
||||
|
||||
- (NSUInteger)leadingWhitespaceLength
|
||||
{
|
||||
const char *str = self.UTF8String;
|
||||
|
||||
Reference in New Issue
Block a user