View Single Post
Old 01-02-2021, 07:10 PM   #31
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,893
Karma: 6120478
Join Date: Nov 2009
Device: many
Took a look at the code in CNode.cpp and it is so thin a wrapper around GumboNode* that it does not handle the code of a NULL node. It has this problem all throughout the code in that file.

It will have to be rewritten and hardened.

Thanks for the head's up!

Quote:
Originally Posted by Frenzie View Post
Since it's about selecting elements rather than actually applying styles, it doesn't look like the likes of ::first-line and ::first-letter are supported. You'd have to remove those before passing it on.

https://github.com/lazytiger/gumbo-q....cpp#L382-L523

Btw, if you try something like this (p:first-child:first-of-type) it gives you a segmentation fault:
Code:
void test_html() {
	std::string page = "<html><div class=\"chapter\"><p class=\"flush\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p><p>second child</p></div></html>";
	CDocument doc;
	doc.parse(page.c_str());
	CNode pNode = doc.find(".chapter > p:first-child:first-of-type").nodeAt(0);
	std::string content = page.substr(pNode.startPos(), pNode.endPos() - pNode.startPos());
	printf("Node: #%s#\n", content.c_str());
}
(Silly example? Absolutely. But what else does one test for. ^_^)
KevinH is offline   Reply With Quote