-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Escape dollar sign for saving content into crontab #26462
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
Conversation
The crontab contents can contain dollar sign (e.g. $(date)). The current code does not escape it which transform it to actual values. In this commit a replacement to escape dollar sign is added to the previous replacements.
Hi @Erfans. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Erfans,
Unfortunately steps to reproduce isn't clear how to test it. Could you explain 1st step more detailed?
In general your changes looks good.
Could you cover your changes with unit or integration test, so we'll not brake this functionality in future?
for reproducing step 1:
the for unit test perhaps I can add it in the next week. |
@Erfans ok, so we’ll wait for test coverage |
I will take care of test coverage. |
lib/internal/Magento/Framework/Crontab/Test/Unit/CrontabManagerTest.php
Outdated
Show resolved
Hide resolved
Hi @ihor-sviziev, thank you for the review. |
✔️ QA Passed |
Hi @Erfans, thank you for your contribution! |
The crontab contents can contain dollar sign (e.g. $(date)).
The current code does not escape it which transform it to actual values.
In this commit a replacement to escape dollar sign is added to the previous replacements.
an example in crontab could be
mysqldump db > db-$(date +%F).sql
Description (*)
Class
lib/internal/Magento/Framework/Crontab/CrontabManager.php
functionsave
already replace couple of special characters '%' and '"'. I added a new entry into the replacement to escape dollar sign as well. i.e. convert$
to\$
.Manual testing scenarios (*)
mysqldump -uroot DB >/home/backups/$(date +%F)_db.sql
bin\magento cron:install
$(date +%F)
is transformed to actual date string.bin\magento cron:remove
has the same effect as well.This pull request should fix the conversion, i.e. after
bin\magento cron:install
the content of the other parts with dollar sign should stay intact.Contribution checklist (*)