Merge lp:~pieq/checkbox/fix-1585556-sanitizing-comments into lp:checkbox
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Sylvain Pineau | ||||
Approved revision: | 4410 | ||||
Merged at revision: | 4412 | ||||
Proposed branch: | lp:~pieq/checkbox/fix-1585556-sanitizing-comments | ||||
Merge into: | lp:checkbox | ||||
Diff against target: |
47 lines (+18/-2) 2 files modified
plainbox/plainbox/impl/result.py (+15/-2) plainbox/plainbox/impl/test_result.py (+3/-0) |
||||
To merge this branch: | bzr merge lp:~pieq/checkbox/fix-1585556-sanitizing-comments | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sylvain Pineau (community) | Approve | ||
Review via email: mp+298283@code.launchpad.net |
Description of the change
Sanitize tester comments to avoid crashes when parsing submission file
When using checkbox-cli, tester who type special keys (like Escape, Page Up/Down, arrow keys, etc.) when entering a comment may leave undesirable characters sequences that may prevent submission files from being valid, hence blocking their process in C3.
The proposed merge simply escape the tester comments to avoid this.
Tested this way:
1. Run a test where you can input comments:
plainbox run -i ".*miscellanea/
2. press `c` to enter a comment, then press a few special keys like Esc, arrow keys, PgUp/PgDown keys, etc. then press Enter to validate
→ You can see right away that the comment has been sanitized
3. export the session as an xml file:
plainbox session export -f xml -o /tmp/sub_
4. Check if the submission file is valid:
cat /tmp/sub_
→ no problem \o/
(before, this last command would crash with output like this:)
-------
ERROR plainbox.parsers: Cannot parse input
Traceback (most recent call last):
File "/home/
return self.parser_
File "/home/
parser.
File "/home/
tree = etree.parse(
File "/usr/lib/
tree.
File "/usr/lib/
parser.
File "<string>", line None
xml.etree.
-------
The current CONTROL_CODE_RE_STR does not seem to clean the string from escape sequences (especially those ending with arrow/pagedown).
I'd try to add a new regex for a two step cleanup using this time this one:
'(\x9B| \x1B\[) [0-?]*[ -\/]*[@-~]'
Credits: http:// stackoverflow. com/a/33925425/ 1154487
And we need a new unit test to check it works (and not regress)