@@ -44,11 +44,11 @@ class MusicXMLTests(unittest.TestCase):
|
||||
self.assertEqual(len(score['staves'][0]['measures']), 4)
|
||||
self.assertEqual(len(score['staves'][0]['octave_shifts']), 1)
|
||||
def test_catalog_imports(self):
|
||||
sources = sorted(Path('data').rglob('*.xml'))
|
||||
sources = sorted(path for category in ('practice', 'songs') for path in (Path('data') / category).glob('*.xml'))
|
||||
self.assertTrue(sources)
|
||||
for path in sources:
|
||||
with self.subTest(path=path):
|
||||
self.assertEqual(load_musicxml(path)['schema_version'], 3)
|
||||
self.assertEqual(set(load_musicxml(path)), {'metadata', 'staves'})
|
||||
def test_all_written_values_and_dots(self):
|
||||
for kind in NOTE_TYPES:
|
||||
for dots in (0, 1, 2, 3):
|
||||
@@ -71,7 +71,7 @@ class MusicXMLTests(unittest.TestCase):
|
||||
def test_doctype_allowed_but_entities_rejected(self):
|
||||
source = xml_score(xml_note())
|
||||
source = source.replace('<score-partwise', '<!DOCTYPE score-partwise SYSTEM "https://invalid.test/partwise.dtd"><score-partwise', 1)
|
||||
self.assertEqual(parse(source)['schema_version'], 3)
|
||||
self.assertEqual(parse(source), parse(xml_score(xml_note())))
|
||||
malicious = xml_score(xml_note()).replace('<score-partwise', '<!DOCTYPE score-partwise [<!ENTITY secret SYSTEM "file:///etc/passwd">]><score-partwise', 1)
|
||||
with self.assertRaises(MusicXMLError):
|
||||
parse(malicious)
|
||||
|
||||
Reference in New Issue
Block a user