1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[css2xpath] Do not exit on failure

This commit is contained in:
Witold Filipczyk 2021-10-14 11:56:55 +02:00
parent 85aeb67af0
commit 8ebba7478b
2 changed files with 28 additions and 5 deletions

View File

@ -2029,7 +2029,14 @@ document_querySelector(JSContext *ctx, unsigned int argc, JS::Value *vp)
done_string(&cssstr);
auto elements = root->find(xpath);
xmlpp::Node::NodeSet elements;
try {
elements = root->find(xpath);
} catch (xmlpp::exception) {
args.rval().setNull();
return true;
}
if (elements.size() == 0) {
args.rval().setNull();
@ -2091,7 +2098,12 @@ document_querySelectorAll(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
*elements = root->find(xpath);
try {
*elements = root->find(xpath);
} catch (xmlpp::exception) {
args.rval().setNull();
return true;
}
if (elements->size() == 0) {
args.rval().setNull();

View File

@ -2935,10 +2935,16 @@ element_querySelector(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::ustring css = cssstr.source;
xmlpp::ustring xpath = css2xpath(css);
done_string(&cssstr);
auto elements = el->find(xpath);
xmlpp::Node::NodeSet elements;
try {
elements = el->find(xpath);
} catch (xmlpp::exception) {
args.rval().setNull();
return true;
}
if (elements.size() == 0) {
args.rval().setNull();
@ -2998,7 +3004,12 @@ element_querySelectorAll(JSContext *ctx, unsigned int argc, JS::Value *vp)
xmlpp::Node::NodeSet *elements = new xmlpp::Node::NodeSet;
*elements = el->find(xpath);
try {
*elements = el->find(xpath);
} catch (xmlpp::exception) {
args.rval().setNull();
return true;
}
if (elements->size() == 0) {
args.rval().setNull();