fix all problems I could see with dirs/filenames containing spaces/accented chars...
[booh] / bin / booh
index 6d7cc315ab38e866961110753ad3532dc529c9ff..42db25d6debb8694ade924f53d96957748546c4b 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -144,8 +144,8 @@ def handle_options
     end
 
     if !$source && $xmldoc
-        $source = $xmldoc.root.attributes['source']
-        $dest = $xmldoc.root.attributes['destination']
+        $source = from_utf8($xmldoc.root.attributes['source'])
+        $dest = from_utf8($xmldoc.root.attributes['destination'])
         $theme = $xmldoc.root.attributes['theme']
         $limit_sizes = $xmldoc.root.attributes['limit-sizes']
     end
@@ -339,7 +339,7 @@ end
 
 def walk_source_dir
 
-    `find #{$source} -type d`.sort.each { |dir|
+    `find '#{$source}' -type d`.sort.each { |dir|
         dir.chomp!
         if dir =~ /'/
             die _("Source directory or sub-directories can't contain a single-quote character, sorry.")
@@ -377,9 +377,13 @@ def walk_source_dir
             entries = Dir.entries(dir).sort
             #- populate config in case of gen_config, add new files in case of merge_config
             for file in entries
-                type = entry2type(file)
-                if type && !xmldir.elements["#{type}[@filename='#{utf8(file)}']"]
-                    xmldir.add_element type, { "filename" => utf8(file), "caption" => utf8(file.sub(/\.[^\.]+$/, '')[0..17]) }
+                if file =~ /['"\(\)\[\]]/
+                    msg 1, _("Ignoring %s, contains one of forbidden characters: '\"()[]") % "#{dir}/#{file}"
+                else
+                    type = entry2type(file)
+                    if type && !xmldir.elements["#{type}[@filename='#{utf8(file)}']"]
+                        xmldir.add_element type, { "filename" => utf8(file), "caption" => utf8(file.sub(/\.[^\.]+$/, '')[0..17]) }
+                    end
                 end
             end
             if $mode == 'merge_config'
@@ -632,7 +636,7 @@ def walk_source_dir
     #- second pass to create index.html files
     msg 3, _("\trescanning directories to generate all `index.html' files...")
 
-    `find #{$source} -type d`.each { |dir|
+    `find '#{$source}' -type d`.each { |dir|
         dir.chomp!
         xmldir = $xmldoc.elements["//dir[@path='#{utf8(dir)}']"]
         if !xmldir