@@ -58,10 +58,11 @@ def send_message(message):
5858
5959
6060def add_jabref_entry (data ):
61- cmd = f'{ str (JABREF_PATH )} --importBibtex """{ data } """'
61+ """Send string via cli as literal to preserve special characters"""
62+ cmd = [str (JABREF_PATH ), "--importBibtex" , r"{}" .format (data )]
6263 logging .info (f"Try to execute command { cmd } " )
6364 try :
64- response = subprocess .check_output (shlex . split ( cmd ) , stderr = subprocess .STDOUT )
65+ response = subprocess .check_output (cmd , stderr = subprocess .STDOUT )
6566 except subprocess .CalledProcessError as exc :
6667 logging .error (f"Failed to call JabRef: { exc .returncode } { exc .output } " )
6768 else :
@@ -78,9 +79,9 @@ def add_jabref_entry(data):
7879logging .info (str (message ))
7980
8081if "status" in message and message ["status" ] == "validate" :
81- cmd = str (JABREF_PATH ) + " - version"
82+ cmd = [ str (JABREF_PATH ), "-- version"]
8283 try :
83- response = subprocess .check_output (shlex . split ( cmd ) , stderr = subprocess .STDOUT )
84+ response = subprocess .check_output (cmd , stderr = subprocess .STDOUT )
8485 except subprocess .CalledProcessError as exc :
8586 logging .error (f"Failed to call JabRef: { exc .returncode } { exc .output } " )
8687 send_message ({"message" : "jarNotFound" , "path" : JABREF_PATH })
0 commit comments