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
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. ^_^)
|