mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-30 06:43:03 +00:00 
			
		
		
		
	Fix for caliber-convert parameter recognition bug with spaces in parameter (fix for #3189)
This commit is contained in:
		| @@ -282,22 +282,30 @@ class TaskConvert(CalibreTask): | |||||||
|                         if not ele.startswith('Traceback') and not ele.startswith('  File'): |                         if not ele.startswith('Traceback') and not ele.startswith('  File'): | ||||||
|                             error_message = N_("Calibre failed with error: %(error)s", error=ele) |                             error_message = N_("Calibre failed with error: %(error)s", error=ele) | ||||||
|                     return check, error_message |                     return check, error_message | ||||||
|             quotes = [1, 2, 4, 6] |             quotes = [1, 2] | ||||||
|  |             quotes_index = 4 | ||||||
|             command = [config.config_converterpath, (file_path + format_old_ext), |             command = [config.config_converterpath, (file_path + format_old_ext), | ||||||
|                        (file_path + format_new_ext)] |                        (file_path + format_new_ext), "-v", "-v"] | ||||||
|             if config.config_embed_metadata: |             if config.config_embed_metadata: | ||||||
|  |                 quotes.append([4]) | ||||||
|  |                 quotes_index = 5 | ||||||
|                 command.extend(['--from-opf', path_tmp_opf]) |                 command.extend(['--from-opf', path_tmp_opf]) | ||||||
|                 if has_cover: |                 if has_cover: | ||||||
|  |                     quotes.append([6]) | ||||||
|                     command.extend(['--cover', os.path.join(os.path.dirname(file_path), 'cover.jpg')]) |                     command.extend(['--cover', os.path.join(os.path.dirname(file_path), 'cover.jpg')]) | ||||||
|             # quotes_index = 3 |                     quotes_index = 7 | ||||||
|             if config.config_calibre: |             if config.config_calibre: | ||||||
|                 parameters = re.findall(r"--[\w-]+(?:(\s(?:(\".+\")|(?:.+?)|(?:(\'.+\'))))(?:\s|$))?", |                 parameters = re.findall(r"(--[\w-]+)(?:(\s(?:(\".+\")|(?:.+?)))(?:\s|$))?", | ||||||
|                                         config.config_calibre, re.IGNORECASE | re.UNICODE) |                                         config.config_calibre, re.IGNORECASE | re.UNICODE) | ||||||
|                 if parameters: |                 if parameters: | ||||||
|                     for param in parameters: |                     for param in parameters: | ||||||
|                         command.append(param) |                         command.append(strip_whitespaces(param[0])) | ||||||
|                         #quotes.append(quotes_index) |                         quotes_index += 1 | ||||||
|                         #quotes_index += 1 |                         if param[1] != "": | ||||||
|  |                             parsed = strip_whitespaces(param[1]).strip("\"") | ||||||
|  |                             command.append(parsed) | ||||||
|  |                             quotes.append(quotes_index) | ||||||
|  |                             quotes_index += 1 | ||||||
|             p = process_open(command, quotes, newlines=False) |             p = process_open(command, quotes, newlines=False) | ||||||
|         except OSError as e: |         except OSError as e: | ||||||
|             return 1, N_("Ebook-converter failed: %(error)s", error=e) |             return 1, N_("Ebook-converter failed: %(error)s", error=e) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ozzie Isaacs
					Ozzie Isaacs