Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lost MyHTML_TOKEN_TYPE_DONE on invalid <br> tag #187

Open
Azq2 opened this issue Jun 26, 2021 · 0 comments
Open

Lost MyHTML_TOKEN_TYPE_DONE on invalid <br> tag #187

Azq2 opened this issue Jun 26, 2021 · 0 comments

Comments

@Azq2
Copy link
Contributor

Azq2 commented Jun 26, 2021

<svg></br><foo>

Code for reproduce:

#include <stdio.h>
#include <stdlib.h>

#include <myhtml/myhtml.h>
#include <myhtml/serialization.h>

void dumper(myhtml_tree_node_t *node, size_t level) {
	while (node) {
		for (size_t i = 0; i < level; i++)
			fprintf(stderr, "    ");
		fprintf(stderr, "<%ld token='%s'>\n", node->tag_id, (node->token ? (node->token->type & MyHTML_TOKEN_TYPE_DONE ? "DONE" : "NOT DONE") : "NULL"));
		
		if (node->child)
			dumper(node->child, level + 1);
		
		for (size_t i = 0; i < level; i++)
			fprintf(stderr, "    ");
		fprintf(stderr, "</%ld>\n", node->tag_id);
		
		node = node->next;
	}
}

int main(int argc, const char * argv[]) {
	const char* html = "<svg></br><foo>";

	// basic init
	myhtml_t* myhtml = myhtml_create();
	myhtml_init(myhtml, MyHTML_OPTIONS_DEFAULT, 1, 0);

	// init tree
	myhtml_tree_t* tree = myhtml_tree_create();
	myhtml_tree_init(tree, myhtml);

	// parse html
	myhtml_parse(tree, MyENCODING_UTF_8, html, strlen(html));
	
	myhtml_tree_node_t *node = myhtml_tree_get_document(tree);
	dumper(node, 0);
	
    return 0;
}

Output:

<0 token='NULL'>
    <65 token='NULL'>
        <61 token='NULL'>
        </61>
        <23 token='NULL'>
            <124 token='DONE'>
                <24 token='NOT DONE'>
                </24>
                <252 token='DONE'>
                </252>
            </124>
        </23>
    </65>
</0>

Token in tag with id=24 (MyHTML_TAG_BR) without flag MyHTML_TOKEN_TYPE_DONE

@Azq2 Azq2 mentioned this issue Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant