]> Some of my projects - localmylist.git/commitdiff
Make the regex for the automagical FileName sanitize configurable.
authorAPTX <redacted>
Thu, 25 Apr 2013 14:21:29 +0000 (16:21 +0200)
committerAPTX <redacted>
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 5083a46..f06b03a 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 3658387..1f3165d 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);