"Fix" crash on empty text
https://ruby.social/@CoralineAda/109951421922797743
This commit is contained in:
parent
6cb53f1bc1
commit
5e1efca040
|
@ -204,7 +204,9 @@ std::string get_text_content(lxb_dom_node_t* child) {
|
||||||
while (remove_from && out[remove_from - 1] == '\n') {
|
while (remove_from && out[remove_from - 1] == '\n') {
|
||||||
remove_from--;
|
remove_from--;
|
||||||
}
|
}
|
||||||
if (out.size() > remove_from) {
|
// Don't engulf everything, otherwise it crashes
|
||||||
|
// https://ruby.social/@CoralineAda/109951421922797743
|
||||||
|
if (out.size() > remove_from && remove_from != 0) {
|
||||||
out.erase(remove_from);
|
out.erase(remove_from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +215,11 @@ std::string get_text_content(lxb_dom_node_t* child) {
|
||||||
while (out.size() > remove_to && out[remove_to] == '\n') {
|
while (out.size() > remove_to && out[remove_to] == '\n') {
|
||||||
remove_to++;
|
remove_to++;
|
||||||
}
|
}
|
||||||
out.erase(0, remove_to);
|
// Don't engulf everything, otherwise it crashes
|
||||||
|
// https://ruby.social/@CoralineAda/109951421922797743
|
||||||
|
if (out.size() > remove_to) {
|
||||||
|
out.erase(0, remove_to);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
Loading…
Reference in New Issue