Log Message: |
entries-dump: Escape string-typed attribute values when serializing
them as Python string literals.
Before this commit, a filesystem node named "foo\bar" (a single,
7-character path component) would cause "e.name = 'foo\bar'" to be
emitted. In genral, the unescaped backslash would manifest as a test
failure or a SyntaxError, depending on the following characters.
This was triggered by update_tests.py 76 windows_update_backslash under
Python 3 on Windows.
There can be some other characters that should be escaped. For example,
user names can contain "'" (a single quote character) and/or """ (a
double quote character), which would potentially cause a SyntaxError
even if we choose either of them to quote string literals. To avoid
overlooking such potentially unsafe characters, I decided to use hex
value escape for all characters.
Furthermore, to ensure that values are decoded to Unicode as UTF-8 byte
sequences when we use hex value escape under Python 3, we print them as
bytes values and then encode them.
* subversion/tests/cmdline/entries-dump.c
(print_prefix): New function.
(str_value):
- Add argument to specify pool.
- Print human readable value of "value" as is in comment, then set it
as str value by using hex escaped bytes literal.
(entries_dump): Add pool argument to str_value() calls.
(main):
- Print "Entry" class definition as prefix before entry_dump() or tree_dump()
- Style fix on if statement (using blocks).
(): Add include files for assert() and svn_xml_escape_attr_cstring()
* subversion/tests/cmdline/svntest/main.py
(run_entiresdump, run_entriesdump_tree): Move definition of "Entry" class
into generated code by entries-dump execution.
Found by: svn-windows-ra buildbot
Reviewed By: danielsh
|