From bdf9a866519df1307700c31ddf4584aff6ffb2f4 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 5 Jun 2021 15:20:40 +0200 Subject: [PATCH] Fix pagebreak-regex and range in which pagebreaks are searched. --- src/search.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 99f69e6..75ebfc8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -129,8 +129,9 @@ void cleanup_text(string &text) { static const boost::regex re_header_start{"<[hH][1-6]"}; static const boost::regex re_header_end{"]+pagebreak[^>]+" + "(title|aria-label)" + "=\"([[:alnum:]]+)\""}; size_t pos{}; while ((pos = text.find('<', pos)) != string::npos) @@ -149,8 +150,8 @@ void cleanup_text(string &text) { auto endpos{text.find('>')}; boost::match_results match; - if (boost::regex_search(text.substr(pos, endpos).data(), match, - re_pagebreak)) + if (boost::regex_search(text.substr(pos, endpos - pos).data(), + match, re_pagebreak)) { // FIXME: -fsanitize=address is complaining about this. ↓ 🤷 // Could not reproduce it.