-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add module_utils and filters for quoting and unquoting #53
Add module_utils and filters for quoting and unquoting #53
Conversation
Codecov Report
@@ Coverage Diff @@
## main #53 +/- ##
==========================================
+ Coverage 80.06% 83.37% +3.31%
==========================================
Files 11 14 +3
Lines 1304 1480 +176
Branches 181 198 +17
==========================================
+ Hits 1044 1234 +190
+ Misses 193 189 -4
+ Partials 67 57 -10
Continue to review full report at Codecov.
|
…make proper parsing of WHERE possible.
I think this PR is ready now. While making the parsing stricter, I noticed that using the command split function for The (minimal) docs I've added for the quoting/unquoting filters can be seen here: https://ansible.fontein.de/collections/community/routeros/docsite/quoting.html ready_for_review |
(I've added an example to the |
I do a quick test with
Which look ok however this add some "artefacts" to the actual script
After every end of line we get additional 'n' I guess must be '\n'
is added as
Also if we add spaces after end of the line this is more clear indicator for issue with parsing '\n'
Same is and for not so complex strings like comments
Probably will be more easy for you to check that! |
@NikolayDachev sorry, there was a stupid bug in the parsing code (which screwed up escape sequences). I've fixed it, added a lot of tests, and also improved the quoting code so that all control characters (ASCII < 32) are always escaped. |
From what I test so far (add, update remove, query, cmd ) everything work perfectly fine . |
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.
No issues found, work as expected
I think we can merge if no other objections ? |
Thanks ! |
@NikolayDachev thanks for reviewing and testing! |
SUMMARY
These allow to split RouterOS commands (basically what the api module internally does), quote argument values (
"this is a comment\nin multiple lines" | community.routeros.quote_argument_value == "\"this is a comment\\nin multiple lines\""
), quote arguments ("name=with spaces" | community.routeros.quote_argument == "name=\"with spaces\""
), or lists of arguments.This also adds integration tests to CI for testing the filters.
What's missing is some documentation.
CC @heuels @NikolayDachev
ISSUE TYPE
COMPONENT NAME
quoting filters