Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File name is not escaped properly #5

Open
mjy9088 opened this issue Feb 9, 2022 · 0 comments
Open

File name is not escaped properly #5

mjy9088 opened this issue Feb 9, 2022 · 0 comments

Comments

@mjy9088
Copy link

mjy9088 commented Feb 9, 2022

vscode extension version: v0.0.4

test file name: This file have " in filename "

error message

Traceback (most recent call last):
  File "/Users/user/Library/Python/3.8/lib/python/site-packages/proselint/command_line.py", line 146, in proselint
    f = click.open_file(fp, 'r', "utf-8", "replace")
  File "/Users/user/Library/Python/3.8/lib/python/site-packages/click/utils.py", line 367, in open_file
    f, should_close = open_stream(filename, mode, encoding, errors, atomic=atomic)
  File "/Users/user/Library/Python/3.8/lib/python/site-packages/click/_compat.py", line 404, in open_stream
    return _wrap_io_open(filename, mode, encoding, errors), True
  File "/Users/user/Library/Python/3.8/lib/python/site-packages/click/_compat.py", line 379, in _wrap_io_open
    return open(file, mode, encoding=encoding, errors=errors)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/user/workspace/personal/public/blog/This file have '

sure, not working on $ sign too

code:

    public checkDocument(document: vscode.TextDocument = vscode.window.activeTextEditor.document) {
        shelljs.exec(`proselint --json "${document.fileName}"`, (code, output, error) => {
//                                     ^
//                               problem here!
            this.proseLintResult(document, code, output, error);
        });
    }

My suggestion: Use spawn instead of exec, and get free from escape hell!

exec(`proselint --json "${shellEscape(document.fileName)}"`) ...

// =============================================================

spawn(exePath, ["--json", "--", document.fileName]) ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant