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:
@ -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())
|
||||
|
Reference in New Issue
Block a user