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

Update processing to be more general #26

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Update processing to be more general #26

merged 2 commits into from
Oct 28, 2024

Conversation

lnauta
Copy link
Member

@lnauta lnauta commented Oct 28, 2024

The eval implementation assumes certain forms for input which results in complex strings from the token to be parsed into commands. This is unwanted, as programs can generate quite complicated commands in string form, with different shapes (for safety for ex.) like single-, double- quotes, backticks, and other characters that bash, python and json may interpret/parse differently.

The implementation in this commit changes the bash part to leave the input string intact, and not split it into pieces. Moreover, the shell part of python is changed into default behaviour of subprocess, along with listing the input, which also helps with parsing complex strings properly.

This was tested with string containing escaped characters in nested and nonnested forms, and is more robust:

echo 'Single quote' && echo "Double quote" && echo && echo \Escaped backslash\
echo "this is a test"; echo 'nesting with "double quotes" and backticks'
(This is probably already parsed and reparsed by the github comments)

lnauta and others added 2 commits October 11, 2024 09:48
The eval implementation assumes certain forms for input
which results in complex strings from the token to be
parsed into commands. This is unwanted, as programs can
generate quite complicated commands in string form, with
different shapes (for safety for ex.) like single-, double-
quotes, backticks, and other characters that bash, python
and json may interpret/parse differently.

The implementation in this commit changes the bash part to
leave the input string intact, and not split it into pieces.
Moreover, the shell part of python is changed into default
behaviour of subprocess, along with listing the input,
which also helps with parsing complex strings properly.

This was tested with string containing escaped characters
in nested and nonnested forms, and is more robust.
@lnauta lnauta requested a review from hailihu October 28, 2024 08:05
@hailihu
Copy link
Collaborator

hailihu commented Oct 28, 2024

I tested this PR by creating tokens with python pushTokens.py quickExample.txt, with quickExample.txt:

echo 'single quote'
echo "double quote" 
echo \`backtick command\`
echo \escaped backslash\
echo \"this is a test\"
echo 'nesting with \"double quotes\" and `backticks`'
echo 'nesting with "double quotes" and `backticks`'

Then running python local-example.py and checking the log_token_*.out attachments. This works as expected.

@hailihu hailihu merged commit 6c1a529 into master Oct 28, 2024
4 checks passed
@lnauta lnauta deleted the SPD-415 branch October 29, 2024 10:56
@lnauta lnauta restored the SPD-415 branch October 30, 2024 15:57
@lnauta
Copy link
Member Author

lnauta commented Oct 30, 2024

I have not added any tests, I will work on that.

@hailihu hailihu deleted the SPD-415 branch November 8, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants