mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-05-08 09:49:51 +00:00
[#95 state:fixed] Fixed a crash on results save when it contained invalid characters.
This commit is contained in:
parent
4d66b4667c
commit
ac1593ff75
@ -284,9 +284,12 @@ class Results(Markable):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
words = ()
|
words = ()
|
||||||
file_elem = etree.SubElement(group_elem, 'file')
|
file_elem = etree.SubElement(group_elem, 'file')
|
||||||
file_elem.set('path', unicode(d.path))
|
try:
|
||||||
|
file_elem.set('path', unicode(d.path))
|
||||||
|
file_elem.set('words', ','.join(words))
|
||||||
|
except ValueError: # If there's an invalid character, just skip the file
|
||||||
|
file_elem.set('path', '')
|
||||||
file_elem.set('is_ref', ('y' if d.is_ref else 'n'))
|
file_elem.set('is_ref', ('y' if d.is_ref else 'n'))
|
||||||
file_elem.set('words', ','.join(words))
|
|
||||||
file_elem.set('marked', ('y' if self.is_marked(d) else 'n'))
|
file_elem.set('marked', ('y' if self.is_marked(d) else 'n'))
|
||||||
for match in g.matches:
|
for match in g.matches:
|
||||||
match_elem = etree.SubElement(group_elem, 'match')
|
match_elem = etree.SubElement(group_elem, 'match')
|
||||||
|
@ -574,6 +574,12 @@ class TCResultsXML(TestCase):
|
|||||||
# apply_filter() searches on the whole path, not just on the filename.
|
# apply_filter() searches on the whole path, not just on the filename.
|
||||||
self.results.apply_filter(u'basepath')
|
self.results.apply_filter(u'basepath')
|
||||||
eq_(len(self.results.groups), 2)
|
eq_(len(self.results.groups), 2)
|
||||||
|
|
||||||
|
def test_save_xml_with_invalid_characters(self):
|
||||||
|
# Don't crash when saving files that have invalid xml characters in their path
|
||||||
|
self.objects[0].name = u'foo\x19'
|
||||||
|
self.results.save_to_xml(StringIO.StringIO()) # don't crash
|
||||||
|
|
||||||
|
|
||||||
class TCResultsFilter(TestCase):
|
class TCResultsFilter(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user