forked from qt-creator/qt-creator
QmlProjectExporter: Refuse to read qmldir files from illegal locations
Change-Id: Ifafbb252c38ed4b384abf4dcaeb9b3b2cbe8684e Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -255,12 +255,36 @@ bool CMakeGenerator::isMockModule(const NodePtr &node) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CMakeGenerator::checkQmlDirLocation(const Utils::FilePath &filePath) const
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_root, return false);
|
||||||
|
QTC_ASSERT(buildSystem(), return false);
|
||||||
|
|
||||||
|
Utils::FilePath dirPath = filePath.parentDir().cleanPath();
|
||||||
|
Utils::FilePath rootPath = m_root->dir.cleanPath();
|
||||||
|
if (dirPath==rootPath)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (const QString &path : buildSystem()->allImports()) {
|
||||||
|
Utils::FilePath importPath = rootPath.pathAppended(path).cleanPath();
|
||||||
|
if (dirPath==importPath)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CMakeGenerator::readQmlDir(const Utils::FilePath &filePath, NodePtr &node) const
|
void CMakeGenerator::readQmlDir(const Utils::FilePath &filePath, NodePtr &node) const
|
||||||
{
|
{
|
||||||
node->uri = "";
|
node->uri = "";
|
||||||
node->name = "";
|
node->name = "";
|
||||||
node->singletons.clear();
|
node->singletons.clear();
|
||||||
|
|
||||||
|
if (!checkQmlDirLocation(filePath)) {
|
||||||
|
QString text("Unexpected location for qmldir file.");
|
||||||
|
logIssue(ProjectExplorer::Task::Warning, text, filePath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isMockModule(node))
|
if (isMockModule(node))
|
||||||
node->type = Node::Type::MockModule;
|
node->type = Node::Type::MockModule;
|
||||||
else
|
else
|
||||||
|
@@ -44,6 +44,7 @@ private:
|
|||||||
bool ignore(const Utils::FilePath &path) const;
|
bool ignore(const Utils::FilePath &path) const;
|
||||||
bool checkUri(const QString& uri, const Utils::FilePath &path) const;
|
bool checkUri(const QString& uri, const Utils::FilePath &path) const;
|
||||||
bool isMockModule(const NodePtr &node) const;
|
bool isMockModule(const NodePtr &node) const;
|
||||||
|
bool checkQmlDirLocation(const Utils::FilePath &path) const;
|
||||||
|
|
||||||
void createCMakeFiles(const NodePtr &node) const;
|
void createCMakeFiles(const NodePtr &node) const;
|
||||||
void createSourceFiles() const;
|
void createSourceFiles() const;
|
||||||
|
Reference in New Issue
Block a user