Fix segfault on malformed message-part paths
When the part path is multilevel and a non-terminal index is out-of-range, the code would try obtain a
QAbstractItemModel * from an empty
QModelIndex, which is a
nullptr, and then try to call something through that model. That's a segfault.
call pathToPart() on Trojita-specific URLs only
The code was feeding all URLs through the
MsgPartNetAccessManager::pathToPart(). This had a side effect that those URLs whose paths looked like a path from a valid Trojita-specific URL would try to walk the part tree. This in itself is not a problem (
pathToPart() is public API and therefore it should not make any assumptions about URL validity), but as the previous commit shows, sometimes mistakes happen. The funny URL looks like this one:
pathToPart() only makes sense on Trojita-specific URLs, call that just in that case.
refactor: pathToPart: simplify
The "not a number" case is not special in any way, so let's reflect that in the code.
refactor: pathToPart: there's no special handling for empty paths
The comments would try to imply that there's some magic for a path that's just
/. There's no such check, so let's remove that comment.
Also, don't talk about
QString::SkipEmptyParts which the code used to use many, many years ago.
Also move the
ok to where it belongs.
Fixes: 35ff866e Use QByteArray for various IMAP-related paths