Skip to content

Commit 03c1029

Browse files
LyzardKingkoppor
authored andcommitted
Use python raw string to preserve all special characters (#5589)
in bibtex json when importing from web extension.
1 parent d1484f8 commit 03c1029

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

buildres/linux/jabrefHost.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ def send_message(message):
5858

5959

6060
def 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):
7879
logging.info(str(message))
7980

8081
if "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

Comments
 (0)