11 #include <parserutils/charset/mibenum.h> 32 static uint16_t utf16, utf16be, utf16le;
33 uint16_t charset_enc = 0;
34 uint16_t content_type_enc = 0;
49 utf16 = parserutils_charset_mibenum_from_name(
50 "utf-16",
SLEN(
"utf-16"));
51 utf16be = parserutils_charset_mibenum_from_name(
52 "utf-16be",
SLEN(
"utf-16be"));
53 utf16le = parserutils_charset_mibenum_from_name(
54 "utf-16le",
SLEN(
"utf-16le"));
55 assert(utf16 != 0 && utf16be != 0 && utf16le != 0);
62 (
const uint8_t *)
"charset",
63 SLEN(
"charset")) ==
true) {
65 charset_enc = parserutils_charset_mibenum_from_name(
69 (
const uint8_t *)
"content",
70 SLEN(
"content")) ==
true) {
78 if (charset_enc == 0 && content_type_enc != 0)
79 charset_enc = content_type_enc;
81 if (charset_enc != 0) {
87 if (charset_enc == utf16le || charset_enc == utf16be ||
88 charset_enc == utf16) {
89 charset_enc = parserutils_charset_mibenum_from_name(
90 "UTF-8",
SLEN(
"UTF-8"));
93 name = parserutils_charset_mibenum_to_name(charset_enc);
113 bool handled =
false;
115 switch (token->
type) {
141 }
else if (type ==
META) {
143 }
else if (type ==
TITLE) {
159 }
else if (type ==
SCRIPT) {
164 }
else if (type ==
HEAD) {
178 }
else if (type ==
HTML || type ==
BODY || type ==
BR) {
hubbub_error process_comment_append(hubbub_treebuilder *treebuilder, const hubbub_token *token, void *parent)
Process a comment token, appending it to the given parent.
hubbub_token_type type
The token type.
void * ctx
Context pointer.
hubbub_string name
Tag name.
hubbub_tree_handler * tree_handler
Callback table.
const uint8_t * ptr
Pointer to data.
hubbub_error process_characters_expect_whitespace(hubbub_treebuilder *treebuilder, const hubbub_token *token, bool insert_into_current_node)
Process a character token in cases where we expect only whitespace.
hubbub_string value
Attribute value.
hubbub_string name
Attribute name.
insertion_mode mode
The current insertion mode.
size_t len
Byte length of string.
hubbub_tree_encoding_change encoding_change
Change encoding.
uint16_t hubbub_charset_parse_content(const uint8_t *value, uint32_t valuelen)
Parse a content= attribute's value.
hubbub_error handle_in_body(hubbub_treebuilder *treebuilder, const hubbub_token *token)
Handle tokens in "in body" insertion mode.
bool enable_scripting
Whether scripting is enabled.
hubbub_treebuilder_context context
Our context.
hubbub_error insert_element(hubbub_treebuilder *treebuilder, const hubbub_tag *tag_name, bool push)
Create element and insert it into the DOM, potentially pushing it on the stack.
hubbub_error handle_in_head(hubbub_treebuilder *treebuilder, const hubbub_token *token)
Handle token in "in head" insertion mode.
hubbub_attribute * attributes
Array of attribute data.
hubbub_tree_unref_node unref_node
Unreference node.
hubbub_ns
Possible namespaces.
union hubbub_token::@3 data
Type-specific data.
static hubbub_error process_meta_in_head(hubbub_treebuilder *treebuilder, const hubbub_token *token)
Process a meta tag as if "in head".
bool hubbub_string_match(const uint8_t *a, size_t a_len, const uint8_t *b, size_t b_len)
Check that one string is exactly equal to another.
hubbub_error element_stack_pop(hubbub_treebuilder *treebuilder, hubbub_ns *ns, element_type *type, void **node)
Pop an element off the stack of open elements.
element_type element_type_from_name(hubbub_treebuilder *treebuilder, const hubbub_string *tag_name)
Convert an element name into an element type.
void hubbub_charset_fix_charset(uint16_t *charset)
Fix charsets, according to the override table in HTML5, section 8.2.2.2.
element_context * element_stack
Stack of open elements.
uint32_t n_attributes
Count of attributes.
uint32_t current_node
Index of current node in stack.
hubbub_error parse_generic_rcdata(hubbub_treebuilder *treebuilder, const hubbub_token *token, bool rcdata)
Trigger parsing of generic (R)CDATA.