1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.html: fix panic in html.parse() called with empty string, remove replacement of \n in the original content (#17206)

This commit is contained in:
walking devel
2023-02-02 22:32:03 +00:00
committed by GitHub
parent a8102f14be
commit 8cdc554c63
4 changed files with 62 additions and 4 deletions

View File

@ -96,6 +96,12 @@ fn (mut dom DocumentObjectModel) add_tag_by_attribute(tag &Tag) {
fn (mut dom DocumentObjectModel) construct(tag_list []&Tag) {
dom.constructed = true
// If there are no tags, accessing `tag_list` below does panic.
if tag_list.len == 0 {
return
}
mut temp_map := map[string]int{}
mut temp_int := null_element
mut temp_string := ''
@ -106,6 +112,7 @@ fn (mut dom DocumentObjectModel) construct(tag_list []&Tag) {
temp_map['0'] = dom.btree.add_children(tag_list[0])
stack.push(0)
root_index := 0
for index := 1; index < tag_list.len; index++ {
mut tag := tag_list[index]
dom.print_debug(tag.str())