Bug 376419

Summary: Template angle brackets not HTML-escaped in tooltips for clang errors
Product: [Applications] kdevelop Reporter: Nicolás Alvarez <nalvarez>
Component: Language Support: CPP (Clang-based)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.1.0
Sentry Crash Report:

Description Nicolás Alvarez 2017-02-12 22:29:52 UTC
If my C++ code has an error detected by clang parsing, and the error message includes a type with template parameters, the parameters were missing; for example saying "no conversion from 'std::unique_ptr' to 'pointer'" but not including the type passed to unique_ptr.

Since the tooltip uses HTML-based rich text formatting, I suspected it could be because the angle brackets are not escaped, and sure enough that was exactly the problem. Here is a test case:

template<typename T>
class SmartPtr {};

class u{};

void foo(int);
void bar() {
    SmartPtr<u> ptr;
    foo(ptr);
}

Clang will complain that 'SmartPtr<u>' cannot be converted to 'int' when calling 'foo', but since the message is not escaped, <u> will be interpreted as the 'underline' HTML tag, it won't be visible as text, and the tooltip contents after that will appear underlined.
Comment 1 Milian Wolff 2017-02-21 22:59:44 UTC
Git commit 2d04564d564cc1332c9006f47c93e3912c149c65 by Milian Wolff.
Committed on 21/02/2017 at 22:58.
Pushed by mwolff into branch '5.1'.

HTML-escape diagnostic description before showing it in a tooltip

The tooltip displays rich-text, and thus we have to escape contents
before displaying them. This was done already for the main problem's
description, but was missed so far for the sub-diagnostics.

M  +1    -1    language/duchain/navigation/problemnavigationcontext.cpp

https://commits.kde.org/kdevplatform/2d04564d564cc1332c9006f47c93e3912c149c65