diff --git a/src/libs/utils/htmldocextractor.cpp b/src/libs/utils/htmldocextractor.cpp index 0877be15474..41fd38c1ee8 100644 --- a/src/libs/utils/htmldocextractor.cpp +++ b/src/libs/utils/htmldocextractor.cpp @@ -180,28 +180,32 @@ void HtmlDocExtractor::processOutput(QString *html) const return; if (m_mode == FirstParagraph) { - int index = html->indexOf(QLatin1String("
")); - if (index > 0) { - if (html->at(index - 1) == QLatin1Char('.')) { - index += 4; - html->truncate(index); - } else { - //Paragraphs similar to this. Example:
- index = html->lastIndexOf(QLatin1Char('.'), index); - if (index > 0) { - html->truncate(index); - html->append(QLatin1String(".")); + // Try to get the entire first paragraph, but if one is not found or if its opening + // tag is not in the very beginning (using an empirical value as the limit) the html + // is cleared to avoid too much content. + int index = html->indexOf(QLatin1String("")); + if (index != -1 && index < 400) { + index = html->indexOf(QLatin1String("
"), index + 2); + if (index != -1) { + if (html->at(index - 1) == QLatin1Char('.')) { + html->truncate(index + 4); + } else { + //Paragraphs similar to this. Example:
+ index = html->lastIndexOf(QLatin1Char('.'), index); + if (index != -1) { + html->truncate(index); + html->append(QLatin1String(".")); + } } + } else { + html->clear(); } } else { - // Some enumerations don't have paragraphs and just a table with the items. In such - // cases the the html is cleared to avoid showing more that desired. html->clear(); - return; } } - if (m_formatContents) { + if (!html->isEmpty() && m_formatContents) { stripBold(html); replaceNonStyledHeadingsForBold(html); replaceTablesForSimpleLines(html);