This repository was archived by the owner on Feb 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbefore_attribute_name.cpp
More file actions
57 lines (52 loc) · 1.72 KB
/
Copy pathbefore_attribute_name.cpp
File metadata and controls
57 lines (52 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Copyright (C) 2020 Tristan. All Rights Reserved.
* This file is licensed under the BSD 2-Clause license.
* See the COPYING file for licensing information.
*/
#include "before_attribute_name.hpp"
#include <iostream>
#include <vector>
bool
HTML::Tokenizer::BeforeAttributeName::Parse() {
if (context.eof) {
context.reconsume = true;
context.state = HTML::Tokenizer::ParserState::AFTER_ATTRIBUTE_NAME;
} else {
auto &tagToken = context.GetCurrentTagToken();
if (tagToken.attributeName.length() != 0) {
tagToken.AddTokenAttribute(context);
}
switch (context.character) {
case Unicode::CHARACTER_TABULATION:
case Unicode::LINE_FEED:
case Unicode::FORM_FEED:
case Unicode::SPACE:
// Ignore
break;
case Unicode::SOLIDUS:
case Unicode::GREATER_THAN_SIGN:
context.reconsume = true;
context.state = HTML::Tokenizer::ParserState::AFTER_ATTRIBUTE_NAME;
break;
case Unicode::EQUALS_SIGN:
context.LogError(HTML::Tokenizer::ParserError::UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME);
// Correct behavior? The 12.2.5.32 says:
// "Consume the next input chararcter ... Set that
// attribute's name to the current input context.character"
// Note the difference: "next" and "current" input
// context.character!
tagToken.attributeName = Unicode::UString("");
tagToken.attributeName += context.character;
tagToken.attributeValue = Unicode::UString("");
context.state = HTML::Tokenizer::ParserState::ATTRIBUTE_NAME;
break;
default:
tagToken.attributeName = Unicode::UString("");
tagToken.attributeValue = Unicode::UString("");
context.reconsume = true;
context.state = HTML::Tokenizer::ParserState::ATTRIBUTE_NAME;
break;
}
}
return true;
}