forked from qt-creator/qt-creator
Help: Avoid trying to open "Foo::bar" as a url in a browser.
Technically it is a valid URL with scheme "Foo" and path ":bar". With this patch we only try to open URLs with very specific schemes like "qthelp", "file", "http(s)", "about". Task-number: QTCREATORBUG-7547 Change-Id: I6908ff554c12ca0f4cfc5bd0fb30dd659d780a23 Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
This commit is contained in:
@@ -125,6 +125,24 @@ QVariant LocalHelpManager::engineFontSettings()
|
||||
return helpEngine().customValue(Constants::FontKey, QVariant());
|
||||
}
|
||||
|
||||
/*!
|
||||
* Checks if the string does contain a scheme, and if that scheme is a "sensible" scheme for
|
||||
* opening in a internal or external browser (qthelp, about, file, http, https).
|
||||
* This is necessary to avoid trying to open e.g. "Foo::bar" in a external browser.
|
||||
*/
|
||||
bool LocalHelpManager::isValidUrl(const QString &link)
|
||||
{
|
||||
QUrl url(link);
|
||||
if (!url.isValid())
|
||||
return false;
|
||||
const QString scheme = url.scheme();
|
||||
return (scheme == QLatin1String("qthelp")
|
||||
|| scheme == QLatin1String("about")
|
||||
|| scheme == QLatin1String("file")
|
||||
|| scheme == QLatin1String("http")
|
||||
|| scheme == QLatin1String("https"));
|
||||
}
|
||||
|
||||
QByteArray LocalHelpManager::helpData(const QUrl &url)
|
||||
{
|
||||
const QHelpEngineCore &engine = helpEngine();
|
||||
|
||||
Reference in New Issue
Block a user