From: APTX Date: Thu, 25 Apr 2013 14:21:29 +0000 (+0200) Subject: Make the regex for the automagical FileName sanitize configurable. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=a21cc0762ed82377c5c4c4995b9d520e9af76425;p=localmylist.git Make the regex for the automagical FileName sanitize configurable. The default is designed to give valid file names on all Operating Systems. --- diff --git a/localmylist/renamehandler.cpp b/localmylist/renamehandler.cpp index 5083a46..f06b03a 100644 --- a/localmylist/renamehandler.cpp +++ b/localmylist/renamehandler.cpp @@ -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(); diff --git a/localmylist/share/schema/default_config.sql b/localmylist/share/schema/default_config.sql index 3658387..1f3165d 100644 --- a/localmylist/share/schema/default_config.sql +++ b/localmylist/share/schema/default_config.sql @@ -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);