]> Some of my projects - localmylist.git/commitdiff
Make the regex for the automagical FileName sanitize configurable.
authorAPTX <marek321@gmail.com>
Thu, 25 Apr 2013 14:21:29 +0000 (16:21 +0200)
committerAPTX <marek321@gmail.com>
Thu, 25 Apr 2013 14:21:29 +0000 (16:21 +0200)
The default is designed to give valid file names on all Operating Systems.

localmylist/renamehandler.cpp
localmylist/share/schema/default_config.sql

index 5083a465f966f53d6deb793e1af0d035138ec09e..f06b03a543376c756347d16596d059a7286c6142 100644 (file)
@@ -92,7 +92,8 @@ void RenameHandler::handleRename()
                QString newFileName = env.value("FileName", "") + "." + r.value("extension").toString();
                QString newFilePath = env.value("PathName", "");
 
-               newFileName = newFileName.replace(QRegExp("[/\\:*\"?<>|\\r\\n]"), "");
+               QRegExp rx(settings->get("renameSanitizeRegex", QString("[/\\:*\"?<>|\\r\\n]")));
+               newFileName = newFileName.replace(rx, "");
 
                if (newFilePath.isEmpty())
                        newFilePath = oldFile.canonicalPath();
index 365838775b727171bf8261ffc8743148584158aa..1f3165dbbc90948166c74ae4fafd701315d8df0b 100644 (file)
@@ -21,6 +21,7 @@ INSERT INTO config VALUES ('myListDefaultStorage', NULL, true);
 INSERT INTO config VALUES ('myListDefaultSource', NULL, true);
 INSERT INTO config VALUES ('renameScript', NULL, true);
 INSERT INTO config VALUES ('renameLanguage', NULL, true);
+INSERT INTO config VALUES ('renameSanitizeRegex', '[/\:*"?<>|\r\n]', true); -- This assumes \ does not need escaping, which is what current pg does by default.
 INSERT INTO config VALUES ('enableRename', '0', true);
 
 INSERT INTO config VALUES ('fileFilters', '*.mkv *.mp4 *.ogg *.ogm *.wmv *.avi *.mpg *.flv', true);