From 6ed456ed9e243db72f5800f5f1e1677a7f6adc4e Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 27 Nov 2023 12:48:08 +0100 Subject: [PATCH] ClangCodeModel: Fix check for strings that look like file paths Backslashes in the markup string are escaped with another backslash, so we need to check for two consecutive ones on Windows. Otherwise, qdoc/doxygen commands such as "\note" are interpreted as files and trigger expensive I/O operations. Fixes: QTCREATORBUG-29975 Change-Id: I822f57a8612274ff4112063928cab21b9d7ca792 Reviewed-by: David Schulz --- src/plugins/clangcodemodel/clangdclient.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/clangcodemodel/clangdclient.cpp b/src/plugins/clangcodemodel/clangdclient.cpp index 565c8306a0b..09fa96c6e17 100644 --- a/src/plugins/clangcodemodel/clangdclient.cpp +++ b/src/plugins/clangcodemodel/clangdclient.cpp @@ -1139,14 +1139,15 @@ void ClangdClient::gatherHelpItemForTooltip(const HoverRequest::Response &hoverR for (const QString &line : lines) { const QString possibleFilePath = line.simplified(); const auto looksLikeFilePath = [&] { - if (possibleFilePath.length() < 3) + if (possibleFilePath.length() < 4) return false; if (osType() == OsTypeWindows) { - if (possibleFilePath.startsWith(R"(\\)")) + if (possibleFilePath.startsWith(R"(\\\\)")) return true; return possibleFilePath.front().isLetter() && possibleFilePath.at(1) == ':' - && possibleFilePath.at(2) == '\\'; + && possibleFilePath.at(2) == '\\' + && possibleFilePath.at(3) == '\\'; } return possibleFilePath.front() == '/' && possibleFilePath.at(1).isLetterOrNumber();