| 1 |
|
| /* |
| 2 |
|
| Copyright 2015 Alexander Borisov |
| 3 |
|
| |
| 4 |
|
| Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
|
| you may not use this file except in compliance with the License. |
| 6 |
|
| You may obtain a copy of the License at |
| 7 |
|
| |
| 8 |
|
| http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| |
| 10 |
|
| Unless required by applicable law or agreed to in writing, software |
| 11 |
|
| distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
|
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
|
| See the License for the specific language governing permissions and |
| 14 |
|
| limitations under the License. |
| 15 |
|
| |
| 16 |
|
| Author: lex.borisov@gmail.com (Alexander Borisov) |
| 17 |
|
| */ |
| 18 |
|
| |
| 19 |
|
| #include "myhtml/tokenizer_doctype.h" |
| 20 |
|
| |
| 21 |
|
| ///////////////////////////////////////////////////////// |
| 22 |
|
| //// BEFORE DOCTYPE NAME |
| 23 |
|
| //// <!DOCTYPE html%HERE% |
| 24 |
|
| ///////////////////////////////////////////////////////// |
| 25 |
0 |
| size_t myhtml_tokenizer_state_doctype(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 26 |
|
| { |
| 27 |
|
| //myhtml_t* myhtml = tree->myhtml; |
| 28 |
|
| |
| 29 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_DOCTYPE_NAME; |
| 30 |
|
| |
| 31 |
0 |
| return html_offset; |
| 32 |
|
| } |
| 33 |
|
| |
| 34 |
|
| ///////////////////////////////////////////////////////// |
| 35 |
|
| //// BEFORE DOCTYPE NAME |
| 36 |
|
| //// <!DOCTYPE html%HERE% |
| 37 |
|
| ///////////////////////////////////////////////////////// |
| 38 |
0 |
| size_t myhtml_tokenizer_state_before_doctype_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 39 |
|
| { |
| 40 |
0 |
▶ | myhtml_parser_skip_whitespace() |
Branch: 11 branches
| Branch | True | False | Total |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
|
| 41 |
|
| |
| 42 |
0 |
▶ | if(html_offset >= html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset >= html_size) |
0 |
0 |
0 |
|
| 43 |
0 |
| return html_offset; |
| 44 |
|
| |
| 45 |
|
| // TODO: ONLY UP? |
| 46 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 47 |
|
| { |
| 48 |
0 |
| tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS; |
| 49 |
|
| |
| 50 |
0 |
| html_offset++; |
| 51 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 52 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 53 |
|
| |
| 54 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 55 |
|
| } |
| 56 |
|
| else { |
| 57 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode); |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode); |
0 |
0 |
0 |
|
| 58 |
0 |
| tree->attr_current->name_begin = (html_offset + tree->global_offset); |
| 59 |
|
| |
| 60 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DOCTYPE_NAME; |
| 61 |
|
| } |
| 62 |
|
| |
| 63 |
0 |
| return html_offset; |
| 64 |
|
| } |
| 65 |
|
| |
| 66 |
|
| ///////////////////////////////////////////////////////// |
| 67 |
|
| //// DOCTYPE NAME |
| 68 |
|
| //// <!DOCTYPE html%HERE% |
| 69 |
|
| ///////////////////////////////////////////////////////// |
| 70 |
0 |
| size_t myhtml_tokenizer_state_doctype_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 71 |
|
| { |
| 72 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 73 |
|
| { |
| 74 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 75 |
|
| { |
| 76 |
0 |
| tree->attr_current->name_length = (html_offset + tree->global_offset) - tree->attr_current->name_begin; |
| 77 |
|
| |
| 78 |
0 |
| html_offset++; |
| 79 |
|
| |
| 80 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 81 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 82 |
|
| |
| 83 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 84 |
|
| |
| 85 |
0 |
| break; |
| 86 |
|
| } |
| 87 |
0 |
▶ | else if(myhtml_whithspace(html[html_offset], ==, ||)) |
Branch: 5 branches
| Branch | True | False | Total |
| else if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
| else if(myhtml_whithspace(html[html_offset], ==, ||)) |
0 |
0 |
0 |
|
| 88 |
|
| { |
| 89 |
0 |
| tree->attr_current->name_length = (html_offset + tree->global_offset) - tree->attr_current->name_begin; |
| 90 |
|
| |
| 91 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 92 |
|
| |
| 93 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_NAME; |
| 94 |
|
| |
| 95 |
0 |
| html_offset++; |
| 96 |
0 |
| break; |
| 97 |
|
| } |
| 98 |
|
| |
| 99 |
0 |
| html_offset++; |
| 100 |
|
| } |
| 101 |
|
| |
| 102 |
0 |
| return html_offset; |
| 103 |
|
| } |
| 104 |
|
| |
| 105 |
|
| ///////////////////////////////////////////////////////// |
| 106 |
|
| //// AFTER DOCTYPE NAME |
| 107 |
|
| //// <!DOCTYPE html%HERE% |
| 108 |
|
| ///////////////////////////////////////////////////////// |
| 109 |
0 |
| size_t myhtml_tokenizer_state_after_doctype_name(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 110 |
|
| { |
| 111 |
0 |
▶ | myhtml_parser_skip_whitespace() |
Branch: 11 branches
| Branch | True | False | Total |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
|
| 112 |
|
| |
| 113 |
0 |
▶ | if(html_offset >= html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset >= html_size) |
0 |
0 |
0 |
|
| 114 |
0 |
| return html_offset; |
| 115 |
|
| |
| 116 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 117 |
|
| { |
| 118 |
0 |
| html_offset++; |
| 119 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 120 |
|
| |
| 121 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 122 |
0 |
| return html_offset; |
| 123 |
|
| } |
| 124 |
|
| |
| 125 |
0 |
| qnode->begin = (html_offset + tree->global_offset); |
| 126 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_CUSTOM_AFTER_DOCTYPE_NAME_A_Z; |
| 127 |
|
| |
| 128 |
0 |
| return html_offset; |
| 129 |
|
| } |
| 130 |
|
| |
| 131 |
0 |
| size_t myhtml_tokenizer_state_custom_after_doctype_name_a_z(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 132 |
|
| { |
| 133 |
0 |
▶ | if((qnode->begin + 6) > (html_size + tree->global_offset)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if((qnode->begin + 6) > (html_size + tree->global_offset)) { |
0 |
0 |
0 |
|
| 134 |
0 |
| return html_size; |
| 135 |
|
| } |
| 136 |
|
| |
| 137 |
0 |
| const char* param = myhtml_tree_incomming_buf_make_data(tree, qnode, 6); |
| 138 |
|
| |
| 139 |
0 |
▶ | if(myhtml_strncasecmp(param, "PUBLIC", 6) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(myhtml_strncasecmp(param, "PUBLIC", 6) == 0) { |
0 |
0 |
0 |
|
| 140 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode); |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode); |
0 |
0 |
0 |
|
| 141 |
|
| |
| 142 |
0 |
| tree->attr_current->value_begin = qnode->begin; |
| 143 |
0 |
| tree->attr_current->value_length = 6; |
| 144 |
|
| |
| 145 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 146 |
|
| |
| 147 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER; |
| 148 |
|
| |
| 149 |
0 |
| html_offset = (qnode->begin + 6) - tree->incoming_buf->offset; |
| 150 |
|
| } |
| 151 |
0 |
▶ | else if(myhtml_strncasecmp(param, "SYSTEM", 6) == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(myhtml_strncasecmp(param, "SYSTEM", 6) == 0) { |
0 |
0 |
0 |
|
| 152 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode); |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode); |
0 |
0 |
0 |
|
| 153 |
|
| |
| 154 |
0 |
| tree->attr_current->value_begin = qnode->begin; |
| 155 |
0 |
| tree->attr_current->value_length = 6; |
| 156 |
|
| |
| 157 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 158 |
|
| |
| 159 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_PUBLIC_IDENTIFIER; |
| 160 |
|
| |
| 161 |
0 |
| html_offset = (qnode->begin + 6) - tree->incoming_buf->offset; |
| 162 |
|
| } |
| 163 |
|
| else { |
| 164 |
0 |
| tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS; |
| 165 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BOGUS_DOCTYPE; |
| 166 |
|
| } |
| 167 |
|
| |
| 168 |
0 |
| return html_offset; |
| 169 |
|
| } |
| 170 |
|
| |
| 171 |
|
| ///////////////////////////////////////////////////////// |
| 172 |
|
| //// BEFORE DOCTYPE PUBLIC IDENTIFIER |
| 173 |
|
| //// <!DOCTYPE html PUBLIC %HERE%" |
| 174 |
|
| ///////////////////////////////////////////////////////// |
| 175 |
0 |
| size_t myhtml_tokenizer_state_before_doctype_public_identifier(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 176 |
|
| { |
| 177 |
0 |
▶ | myhtml_parser_skip_whitespace() |
Branch: 11 branches
| Branch | True | False | Total |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
|
| 178 |
|
| |
| 179 |
0 |
▶ | if(html_offset >= html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset >= html_size) |
0 |
0 |
0 |
|
| 180 |
0 |
| return html_offset; |
| 181 |
|
| |
| 182 |
0 |
▶ | if(html[html_offset] == '"') { |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '"') { |
0 |
0 |
0 |
|
| 183 |
0 |
| tree->attr_current->value_begin = (html_offset + tree->global_offset) + 1; |
| 184 |
0 |
| tree->attr_current->value_length = 0; |
| 185 |
|
| |
| 186 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED; |
| 187 |
|
| } |
| 188 |
0 |
▶ | else if(html[html_offset] == '\'') { |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '\'') { |
0 |
0 |
0 |
|
| 189 |
0 |
| tree->attr_current->value_begin = (html_offset + tree->global_offset) + 1; |
| 190 |
0 |
| tree->attr_current->value_length = 0; |
| 191 |
|
| |
| 192 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED; |
| 193 |
|
| } |
| 194 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 195 |
|
| { |
| 196 |
0 |
| tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS; |
| 197 |
|
| |
| 198 |
0 |
| html_offset++; |
| 199 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 200 |
|
| |
| 201 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 202 |
0 |
| return html_offset; |
| 203 |
|
| } |
| 204 |
|
| else { |
| 205 |
0 |
| tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS; |
| 206 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BOGUS_DOCTYPE; |
| 207 |
|
| } |
| 208 |
|
| |
| 209 |
0 |
| return (html_offset + 1); |
| 210 |
|
| } |
| 211 |
|
| |
| 212 |
|
| ///////////////////////////////////////////////////////// |
| 213 |
|
| //// DOCTYPE PUBLIC IDENTIFIER DOUBLE or SINGLE QUOTED |
| 214 |
|
| //// <!DOCTYPE html PUBLIC %HERE%" |
| 215 |
|
| ///////////////////////////////////////////////////////// |
| 216 |
0 |
| size_t myhtml_tokenizer_doctype_public_identifier_dsq(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size, char quote) |
| 217 |
|
| { |
| 218 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 219 |
|
| { |
| 220 |
0 |
▶ | if(html[html_offset] == quote) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == quote) |
0 |
0 |
0 |
|
| 221 |
|
| { |
| 222 |
0 |
| tree->attr_current->value_length = (html_offset + tree->global_offset) - tree->attr_current->value_begin; |
| 223 |
|
| |
| 224 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode); |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode); |
0 |
0 |
0 |
|
| 225 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 226 |
|
| |
| 227 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_PUBLIC_IDENTIFIER; |
| 228 |
|
| |
| 229 |
0 |
| html_offset++; |
| 230 |
0 |
| break; |
| 231 |
|
| } |
| 232 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 233 |
|
| { |
| 234 |
0 |
| tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS; |
| 235 |
|
| |
| 236 |
0 |
▶ | if(tree->attr_current->value_begin < (html_offset + tree->global_offset)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->attr_current->value_begin < (html_offset + tree->global_offset)) { |
0 |
0 |
0 |
|
| 237 |
0 |
| tree->attr_current->value_length = (html_offset + tree->global_offset) - tree->attr_current->value_begin; |
| 238 |
|
| |
| 239 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode); |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode); |
0 |
0 |
0 |
|
| 240 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 241 |
|
| } |
| 242 |
|
| |
| 243 |
0 |
| html_offset++; |
| 244 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 245 |
|
| |
| 246 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 247 |
0 |
| break; |
| 248 |
|
| } |
| 249 |
|
| |
| 250 |
0 |
| html_offset++; |
| 251 |
|
| } |
| 252 |
|
| |
| 253 |
0 |
| return html_offset; |
| 254 |
|
| } |
| 255 |
|
| |
| 256 |
0 |
| size_t myhtml_tokenizer_state_doctype_public_identifier_double_quoted(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 257 |
|
| { |
| 258 |
0 |
| return myhtml_tokenizer_doctype_public_identifier_dsq(tree, qnode, html, html_offset, html_size, '"'); |
| 259 |
|
| } |
| 260 |
|
| |
| 261 |
0 |
| size_t myhtml_tokenizer_state_doctype_public_identifier_single_quoted(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 262 |
|
| { |
| 263 |
0 |
| return myhtml_tokenizer_doctype_public_identifier_dsq(tree, qnode, html, html_offset, html_size, '\''); |
| 264 |
|
| } |
| 265 |
|
| |
| 266 |
|
| ///////////////////////////////////////////////////////// |
| 267 |
|
| //// AFTER DOCTYPE PUBLIC IDENTIFIER |
| 268 |
|
| //// <!DOCTYPE html PUBLIC "blah-blah-blah"%HERE%" |
| 269 |
|
| ///////////////////////////////////////////////////////// |
| 270 |
0 |
| size_t myhtml_tokenizer_state_after_doctype_public_identifier(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 271 |
|
| { |
| 272 |
0 |
▶ | myhtml_parser_skip_whitespace() |
Branch: 11 branches
| Branch | True | False | Total |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace() |
0 |
0 |
0 |
|
| 273 |
|
| |
| 274 |
0 |
▶ | if(html_offset >= html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset >= html_size) |
0 |
0 |
0 |
|
| 275 |
0 |
| return html_offset; |
| 276 |
|
| |
| 277 |
0 |
▶ | if(html[html_offset] == '"') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '"') |
0 |
0 |
0 |
|
| 278 |
|
| { |
| 279 |
0 |
| tree->attr_current->value_begin = (html_offset + tree->global_offset) + 1; |
| 280 |
0 |
| tree->attr_current->value_length = 0; |
| 281 |
|
| |
| 282 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED; |
| 283 |
|
| } |
| 284 |
0 |
▶ | else if(html[html_offset] == '\'') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '\'') |
0 |
0 |
0 |
|
| 285 |
|
| { |
| 286 |
0 |
| tree->attr_current->value_begin = (html_offset + tree->global_offset) + 1; |
| 287 |
0 |
| tree->attr_current->value_length = 0; |
| 288 |
|
| |
| 289 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED; |
| 290 |
|
| } |
| 291 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 292 |
|
| { |
| 293 |
0 |
| html_offset++; |
| 294 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 295 |
|
| |
| 296 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 297 |
0 |
| return html_offset; |
| 298 |
|
| } |
| 299 |
|
| else { |
| 300 |
0 |
| tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS; |
| 301 |
|
| |
| 302 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BOGUS_DOCTYPE; |
| 303 |
0 |
| return html_offset; |
| 304 |
|
| } |
| 305 |
|
| |
| 306 |
0 |
| html_offset++; |
| 307 |
|
| |
| 308 |
0 |
| return html_offset; |
| 309 |
|
| } |
| 310 |
|
| |
| 311 |
|
| ///////////////////////////////////////////////////////// |
| 312 |
|
| //// DOCTYPE SYSTEM IDENTIFIER DOUBLE or SINGLE QUOTED |
| 313 |
|
| //// <!DOCTYPE html PUBLIC %HERE%" |
| 314 |
|
| ///////////////////////////////////////////////////////// |
| 315 |
0 |
| size_t myhtml_tokenizer_doctype_system_identifier_dsq(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size, char quote) |
| 316 |
|
| { |
| 317 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 318 |
|
| { |
| 319 |
0 |
▶ | if(html[html_offset] == quote) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == quote) |
0 |
0 |
0 |
|
| 320 |
|
| { |
| 321 |
0 |
| tree->attr_current->value_length = (html_offset + tree->global_offset) - tree->attr_current->value_begin; |
| 322 |
|
| |
| 323 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode); |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode); |
0 |
0 |
0 |
|
| 324 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 325 |
|
| |
| 326 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_AFTER_DOCTYPE_SYSTEM_IDENTIFIER; |
| 327 |
|
| |
| 328 |
0 |
| html_offset++; |
| 329 |
0 |
| break; |
| 330 |
|
| } |
| 331 |
0 |
▶ | else if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| else if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 332 |
|
| { |
| 333 |
0 |
| tree->compat_mode = MyHTML_TREE_COMPAT_MODE_QUIRKS; |
| 334 |
|
| |
| 335 |
0 |
▶ | if(tree->attr_current->value_begin < (html_offset + tree->global_offset)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(tree->attr_current->value_begin < (html_offset + tree->global_offset)) { |
0 |
0 |
0 |
|
| 336 |
0 |
| tree->attr_current->value_length = (html_offset + tree->global_offset) - tree->attr_current->value_begin; |
| 337 |
|
| |
| 338 |
0 |
▶ | myhtml_parser_queue_set_attr(tree, qnode); |
Branch: 1 branch
| Branch | True | False | Total |
| myhtml_parser_queue_set_attr(tree, qnode); |
0 |
0 |
0 |
|
| 339 |
0 |
| myhtml_token_attr_malloc(tree->token, tree->attr_current, tree->token->mcasync_attr_id); |
| 340 |
|
| } |
| 341 |
|
| |
| 342 |
0 |
| html_offset++; |
| 343 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 344 |
|
| |
| 345 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 346 |
0 |
| break; |
| 347 |
|
| } |
| 348 |
|
| |
| 349 |
0 |
| html_offset++; |
| 350 |
|
| } |
| 351 |
|
| |
| 352 |
0 |
| return html_offset; |
| 353 |
|
| } |
| 354 |
|
| |
| 355 |
0 |
| size_t myhtml_tokenizer_state_doctype_system_identifier_double_quoted(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 356 |
|
| { |
| 357 |
0 |
| return myhtml_tokenizer_doctype_system_identifier_dsq(tree, qnode, html, html_offset, html_size, '"'); |
| 358 |
|
| } |
| 359 |
|
| |
| 360 |
0 |
| size_t myhtml_tokenizer_state_doctype_system_identifier_single_quoted(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 361 |
|
| { |
| 362 |
0 |
| return myhtml_tokenizer_doctype_system_identifier_dsq(tree, qnode, html, html_offset, html_size, '\''); |
| 363 |
|
| } |
| 364 |
|
| |
| 365 |
|
| ///////////////////////////////////////////////////////// |
| 366 |
|
| //// AFTER DOCTYPE SYSTEM IDENTIFIER |
| 367 |
|
| //// <!DOCTYPE html PUBLIC "blah-blah-blah"%HERE%" |
| 368 |
|
| ///////////////////////////////////////////////////////// |
| 369 |
0 |
| size_t myhtml_tokenizer_state_after_doctype_system_identifier(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 370 |
|
| { |
| 371 |
0 |
▶ | myhtml_parser_skip_whitespace(); |
Branch: 11 branches
| Branch | True | False | Total |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
| myhtml_parser_skip_whitespace(); |
0 |
0 |
0 |
|
| 372 |
|
| |
| 373 |
0 |
▶ | if(html_offset >= html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| if(html_offset >= html_size) |
0 |
0 |
0 |
|
| 374 |
0 |
| return html_offset; |
| 375 |
|
| |
| 376 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 377 |
|
| { |
| 378 |
0 |
| html_offset++; |
| 379 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 380 |
|
| |
| 381 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 382 |
|
| } |
| 383 |
|
| else { |
| 384 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_BOGUS_DOCTYPE; |
| 385 |
|
| } |
| 386 |
|
| |
| 387 |
0 |
| return html_offset; |
| 388 |
|
| } |
| 389 |
|
| |
| 390 |
|
| ///////////////////////////////////////////////////////// |
| 391 |
|
| //// BOGUS DOCTYPE |
| 392 |
|
| //// find > |
| 393 |
|
| ///////////////////////////////////////////////////////// |
| 394 |
0 |
| size_t myhtml_tokenizer_state_bogus_doctype(myhtml_tree_t* tree, mythread_queue_node_t* qnode, const char* html, size_t html_offset, size_t html_size) |
| 395 |
|
| { |
| 396 |
0 |
▶ | while(html_offset < html_size) |
Branch: 1 branch
| Branch | True | False | Total |
| while(html_offset < html_size) |
0 |
0 |
0 |
|
| 397 |
|
| { |
| 398 |
0 |
▶ | if(html[html_offset] == '>') |
Branch: 1 branch
| Branch | True | False | Total |
| if(html[html_offset] == '>') |
0 |
0 |
0 |
|
| 399 |
|
| { |
| 400 |
0 |
| html_offset++; |
| 401 |
0 |
| myhtml_queue_add(tree, html, html_offset, qnode); |
| 402 |
|
| |
| 403 |
0 |
| myhtml_tokenizer_state_set(tree) = MyHTML_TOKENIZER_STATE_DATA; |
| 404 |
0 |
| break; |
| 405 |
|
| } |
| 406 |
|
| |
| 407 |
0 |
| html_offset++; |
| 408 |
|
| } |
| 409 |
|
| |
| 410 |
0 |
| return html_offset; |
| 411 |
|
| } |
| 412 |
|
| |