Comments (5)
I've confirmed this. Gumbo Parser directly embeds escaped character sequences without modification, yet gumbo-query converts them before building a selector. Gumbo Parser has a massive portion of source code dedicated to converting character references (char_ref.c
), but gumbo-parser does not. So you have a twofold breakdown here. Selectors built to match escaped sequences will never match, and HTML elements that use character references will never match.
The character references issue can be sorted by leveraging the character reference conversion built into gumbo parser, and the parseEscaped method needs to be dropped entirely.
void ConvertCharRefStr(std::string& stringWithCharRef)
{
std::string htmlStr = u8"<html><body><div gqconverted=\"" + stringWithCharRef + u8"\"/></body></html>";
GumboOutput* output = gumbo_parse(htmlStr.c_str());
GumboNode* nodeWithConvertedValue = static_cast<GumboNode*>(static_cast<GumboNode*>(output->root->v.element.children.data[1])->v.element.children.data[0]);
GumboAttribute* a = gumbo_get_attribute(&nodeWithConvertedValue->v.element.attributes, u8"gqconverted");
stringWithCharRef.clear();
stringWithCharRef.assign(a->value);
gumbo_destroy_output(&kGumboDefaultOptions, output);
}
from gumbo-query.
Hi, @TechnikEmpire
You're right about the escape. I've just port the code from go to cpp, and don't do much research about gumbo_parser. I will look into this problem and make a fix. Thanks for the report.
from gumbo-query.
@lazytiger I understand. I'll see if I can help. I'm doing an unofficial fork fixing these things, but also rewriting almost everything, but that's for my own purposes. I'm injecting a bunch of third party dependencies and don't expect it to be pulled from back to here. However, I'll create a separate actual fork, throw in whatever bug fixes I come up with and you can decide if you want to pull them.
from gumbo-query.
@lazytiger I lost track of most of the fixes I made. I tried to do a clone and push fixes but, like I said just lost track. I've finished my rewrite of gumbo-query and renamed it to GQ so it doesn't shadow your project. I've created a ton of tests that can be run in the browser and test programs which verify correct functionality for all types of selectors (over 40 tests). I've also implemented a tree map that makes matching extremely fast. Can find it here https://github.com/TechnikEmpire/GQ if you feel like backporting any of it. Unfortunately due to the full scale rewrite and implementation of boost deps, it wasn't possible to do an official fork and submit PR's.
from gumbo-query.
@TechnikEmpire Thanks for the fixes, I'll see to it later.
from gumbo-query.
Related Issues (20)
- CNode::startPos 与CNode::endPos颠倒的问题 HOT 3
- Crash when select string include '(' char. HOT 1
- Brew formula is wrong
- nth-of-type always select nothing
- add more examples
- Getting the OuterHTML HOT 2
- Getting nodes with a specific class HOT 5
- nth-child(odd) skips first node HOT 3
- CObject destructor can throw, but shouldn't
- Brew unable to install and unable to make HOT 1
- Unable to install Gumbo Query due to it unable to find Gumbo parser shared library HOT 2
- Problems while encoding russian symbols
- Document.h includes gumbo.h which is missing HOT 1
- Where is <gumbo.h> located at in the src folder? i have my own cmake workspace and just need the source code HOT 3
- Trimming strings for advanced datasets HOT 1
- Error: No available formula with the name "gumbo-query"
- Static library not found
- not support css3 selector
- Conan package
- crashed when syntax error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gumbo-query.