forked from qt-creator/qt-creator
Clean the BaseTextDocument filename.
Previously, it could contain multiple directory separators, . or .. This makes using the filename safe for hashes like the ones used in the C++ and Qml code models. Reviewed-by: Roberto Raggi Reviewed-by: mae
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "storagesettings.h"
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QTextCodec>
|
||||
@@ -115,7 +116,7 @@ bool BaseTextDocument::save(const QString &fileName)
|
||||
file.close();
|
||||
|
||||
const QFileInfo fi(fName);
|
||||
m_fileName = fi.absoluteFilePath();
|
||||
m_fileName = QDir::cleanPath(fi.absoluteFilePath());
|
||||
|
||||
m_document->setModified(false);
|
||||
emit titleChanged(fi.fileName());
|
||||
@@ -158,7 +159,7 @@ bool BaseTextDocument::open(const QString &fileName)
|
||||
if (!fileName.isEmpty()) {
|
||||
const QFileInfo fi(fileName);
|
||||
m_fileIsReadOnly = !fi.isWritable();
|
||||
m_fileName = fi.absoluteFilePath();
|
||||
m_fileName = QDir::cleanPath(fi.absoluteFilePath());
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
|
||||
Reference in New Issue
Block a user