From 84a308289c4bc0bc083b6e3bf01746b07cfe1fc3 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 8 Sep 2015 08:03:10 -0500 Subject: [PATCH] Change output_filename_safepattern to replace leading '.' for benefit of *nix OSes. --- fanficfare/defaults.ini | 6 ++++-- fanficfare/story.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 5e3df39..03e0519 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -148,8 +148,10 @@ zip_filename: ${title}-${siteabbrev}_${storyId}${formatext}.zip ## zip_filename. allow_unsafe_filename: false -## The regex pattern of 'unsafe' filename chars for above. -#output_filename_safepattern:[^a-zA-Z0-9_\. \[\]\(\)&'-]+ +## The regex pattern of 'unsafe' filename chars for above. First +## character . OR any one or more characters that are NOT a letter, +## number, or one of _. []()&'- +output_filename_safepattern:(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+) ## entries to make epub subjects and calibre tags ## lastupdate creates two tags: "Last Update Year/Month: %Y/%m" and "Last Update: %Y/%m/%d" diff --git a/fanficfare/story.py b/fanficfare/story.py index bd2d35c..483ccc7 100644 --- a/fanficfare/story.py +++ b/fanficfare/story.py @@ -927,7 +927,7 @@ class Story(Configurable): if not allowunsafefilename: values={} - pattern = re_compile(self.getConfig("output_filename_safepattern",r"[^a-zA-Z0-9_\. \[\]\(\)&'-]+"),"output_filename_safepattern") + pattern = re_compile(self.getConfig("output_filename_safepattern",r"(^\.|/\.|[^a-zA-Z0-9_\. \[\]\(\)&'-]+)"),"output_filename_safepattern") for k in origvalues.keys(): values[k]=re.sub(pattern,'_', removeAllEntities(self.getMetadata(k)))