summaryrefslogtreecommitdiff
path: root/src/instancemanager.cpp
diff options
context:
space:
mode:
authorChris Bessent <lost.dragonist@gmail.com>2021-05-01 14:38:17 -0700
committerGitHub <noreply@github.com>2021-05-01 14:38:17 -0700
commitf098491306f8aea2660bfde5f20dbba97c326301 (patch)
treee4f4fa4ea304198579a5f549aaeb7878bf781676 /src/instancemanager.cpp
parentbcaceb96373cdd0a8ef420850e5c5719e3c6c809 (diff)
parentdc3dcd9500fb7521b01f6707c443e09e8cc69d1c (diff)
Merge pull request #1503 from LostDragonist/filename
Sanitize download file names
Diffstat (limited to 'src/instancemanager.cpp')
-rw-r--r--src/instancemanager.cpp32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp
index a1b17577..e7474584 100644
--- a/src/instancemanager.cpp
+++ b/src/instancemanager.cpp
@@ -32,6 +32,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <iplugingame.h>
#include <utility.h>
#include <log.h>
+#include "filesystemutilities.h"
#include <QCoreApplication>
#include <QDir>
@@ -721,7 +722,7 @@ const MOBase::IPluginGame* InstanceManager::gamePluginForDirectory(
QString InstanceManager::makeUniqueName(const QString& instanceName) const
{
- const QString sanitized = sanitizeInstanceName(instanceName);
+ const QString sanitized = MOBase::sanitizeFileName(instanceName);
// trying "name (N)"
QString name = sanitized;
@@ -742,35 +743,6 @@ bool InstanceManager::instanceExists(const QString& instanceName) const
return root.exists(instanceName);
}
-QString InstanceManager::sanitizeInstanceName(const QString &name) const
-{
- QString new_name = name;
-
- // Restrict the allowed characters
- new_name = new_name.remove(QRegExp("[^A-Za-z0-9 _=+;!@#$%^'\\-\\.\\[\\]\\{\\}\\(\\)]"));
-
- // Don't end in spaces and periods
- new_name = new_name.remove(QRegExp("\\.*$"));
- new_name = new_name.remove(QRegExp(" *$"));
-
- // Recurse until stuff stops changing
- if (new_name != name) {
- return sanitizeInstanceName(new_name);
- }
- return new_name;
-}
-
-bool InstanceManager::validInstanceName(const QString& instanceName) const
-{
- if (instanceName.isEmpty()) {
- return false;
- }
-
- return (instanceName == sanitizeInstanceName(instanceName));
-}
-
-
-
std::unique_ptr<Instance> selectInstance()
{
auto& m = InstanceManager::singleton();