From bd3c824d450ecfddf983f8b3006d36d3490538ca Mon Sep 17 00:00:00 2001 From: Cristian Date: Fri, 4 Sep 2020 10:23:41 -0500 Subject: [PATCH] fix: Escape JSON output on command failure so the user can run the command manually --- .gitignore | 1 + archivebox/extractors/singlefile.py | 5 ++++- package-lock.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0a7034e1..884e1da4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ venv/ build/ dist/ +node_modules/ data/ output/ diff --git a/archivebox/extractors/singlefile.py b/archivebox/extractors/singlefile.py index 0178ca07..8925995b 100644 --- a/archivebox/extractors/singlefile.py +++ b/archivebox/extractors/singlefile.py @@ -42,10 +42,11 @@ def save_singlefile(link: Link, out_dir: Optional[str]=None, timeout: int=TIMEOU browser_args = chrome_args(TIMEOUT=0) # SingleFile CLI Docs: https://github.com/gildas-lormeau/SingleFile/tree/master/cli + browser_args = '--browser-args={}'.format(json.dumps(browser_args[1:])) cmd = [ DEPENDENCIES['SINGLEFILE_BINARY']['path'], '--browser-executable-path={}'.format(CHROME_BINARY), - '--browser-args="{}"'.format(json.dumps(browser_args[1:])), + browser_args, link.url, output ] @@ -73,6 +74,8 @@ def save_singlefile(link: Link, out_dir: Optional[str]=None, timeout: int=TIMEOU chmod_file(output) except (Exception, OSError) as err: status = 'failed' + # TODO: Make this prettier. This is necessary to run the command (escape JSON internal quotes). + cmd[2] = browser_args.replace('"', "\\\"") output = err finally: timer.end() diff --git a/package-lock.json b/package-lock.json index f1483913..69ccfcd0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "archivebox", - "version": "0.4.19", + "version": "0.4.21", "lockfileVersion": 1, "requires": true, "dependencies": {