Unnecessarily stringent test on reslist href format broke spelling replacement

This commit is contained in:
Jean-Francois Dockes 2020-11-17 17:39:07 +01:00
parent 6b7f2ff876
commit f4922687b4

View File

@ -974,8 +974,6 @@ void ResList::onLinkClicked(const QUrl &qurl)
} }
strurl = strurl.substr(m_pager->linkPrefix().size()); strurl = strurl.substr(m_pager->linkPrefix().size());
// The content of our URLs is always a single letter possibly
// followed by an integer value (document number).
if (strurl.size() == 0) { if (strurl.size() == 0) {
return; return;
} }
@ -983,21 +981,16 @@ void ResList::onLinkClicked(const QUrl &qurl)
bool havedoc{false}; bool havedoc{false};
Rcl::Doc doc; Rcl::Doc doc;
if (strurl.size() > 1) { if (strurl.size() > 1) {
// Expecting integer after the letter, and nothing else // If an integer follows interpret as doc number
const char *bptr = strurl.c_str() + 1; const char *bptr = strurl.c_str() + 1;
char *eptr; char *eptr;
docnum = strtol(bptr, &eptr, 10) - 1; docnum = strtol(bptr, &eptr, 10) - 1;
if (eptr == bptr || *eptr != 0) {
// No digits or non-digit characters following digits, bad link.
return;
}
if (docnum >= 0) { if (docnum >= 0) {
if (getDoc(docnum, doc)) { if (getDoc(docnum, doc)) {
havedoc = true; havedoc = true;
} else { } else {
LOGERR("ResList::onLinkClicked: can't get doc for "<< LOGERR("ResList::onLinkClicked: can't get doc for "<<
docnum << "\n"); docnum << "\n");
return;
} }
} }
} }