--- a/chm2pdf	2011-01-16 10:52:29.000000000 +0100
+++ b/chm2pdf	2011-01-16 12:41:26.541000035 +0100
@@ -112,7 +112,7 @@
     takes the list of files inside the chm archive, with the correct urls of each one.
     '''
 
-    os.system('enum_chmLib '+filename+' > '+CHM2PDF_WORK_DIR+'/urlslist.txt')
+    os.system('enum_chmLib "'+filename+'" > "'+CHM2PDF_WORK_DIR+'/urlslist.txt"')
     flist=open(CHM2PDF_WORK_DIR+'/urlslist.txt','rU')
     urls_list=[]
     for line in flist.readlines()[3:]:
@@ -378,7 +378,7 @@
  
         if os.path.exists(page_filename) and (options['titlefile'] == '' or not options['titlefile'] in url):
             htmlout_filename=CHM2PDF_WORK_DIR+'/temp'+'%(#)04d' %{"#":c}+'.html'
-            htmlout_filename_list+=' '+ htmlout_filename
+            htmlout_filename_list+=' "'+ htmlout_filename + '"'
             htmlout_filenames.append(htmlout_filename)
     
             if options['dontextract'] == '':
@@ -583,7 +583,7 @@
            
     if options['verbose']=='--verbose' and options['verbositylevel']=='high':
         print 'htmldoc' + htmldoc_opts + ' ' + htmlout_filename_list + " -f "+ outputfilename + " > /dev/null"
-    exit_value=os.system ('htmldoc' + htmldoc_opts + ' ' + htmlout_filename_list + " -f "+ outputfilename + " > /dev/null")
+    exit_value=os.system ('htmldoc' + htmldoc_opts + ' ' + htmlout_filename_list + ' -f "'+ outputfilename + '" > /dev/null')
 
     if exit_value != 0:
         print 'Something wrong happened when launching htmldoc.'
@@ -1085,9 +1085,9 @@
             print 'Will use the files in ' + CHM2PDF_ORIG_DIR + ' and ' + CHM2PDF_WORK_DIR + '.'
     else:
         if options['verbose'] == '--verbose' and options['verbositylevel'] == 'high':
-            os.system('extract_chmLib ' + filename + ' ' + CHM2PDF_ORIG_DIR)
+            os.system('extract_chmLib "' + filename + '" "' + CHM2PDF_ORIG_DIR + '"')
         else:
-            os.system('extract_chmLib ' + filename + ' ' + CHM2PDF_ORIG_DIR + '&> /dev/null')
+            os.system('extract_chmLib "' + filename + '" "' + CHM2PDF_ORIG_DIR + '" &> /dev/null')
     
     convert_to_pdf(cfile, filename, outputfilename, options)
     shutil.rmtree(CHM2PDF_TEMP_WORK_DIR)