ASCII codes from 26 to 31 are not being escaped correctly
Description
The built-in escape function is not escaping some of the illegal chars.
Reproducing
- Use a string that contains a char in the ASCII range of 26-31, such as
\x1e
- Escape this string using the built-in escape function
openpyxl.utils.escape.escape
- Use this escaped string as content on a new Workbook
Expected outcome
The Workbook would be created normally and can be saved
Actual outcome
openpyxl.utils.exceptions.IllegalCharacterError
Details
The escape function is using [\001-\031]
, which, regardless of what the docstring says, it is not decimal for ASCII 1-31, but instead an octal number that covers the range of 1-25. This means that any chars that are below 31, but above 25 are not being escaped.
Additionally, I also checked that the char \x00 also gives me an IllegalCharacterError
, should we also escape it?