[MusicXML import] incorrect handling of instrument name with ampersand
I Imported a "music-xml" file and saved it as ".mscz-file". When I reopened the .mscz-file i got this error message: XML "Lesefehler in Zeile 539 Spalte 29":
The error occurs always, when there is a "&" sign in the code e.g.
Violin 1 & Oboe (Flute & Clarinet)
Attachment | Size |
---|---|
Kantate No 147.mscx | 620.92 KB |
Comments
Please share the xml file too
Which version of MuseScore and on what OS? Several isues with & have been fixed in 2.1
This sounds very much like #181811: Instrument name with & doesn't save as & if edited by double-click, causing unopenable file which was fixed in version 2.1. Are you using 2.1 or was that the lowest version you could select in the bug report.
In reply to Please share the xml file too by Jojo-Schmitz
I'm using version 2.1.0 and macOS 10.12.
The issue is in the second part, where the track name is properly escaped, but the instrument's long name contains two bare (unescaped) ampersands. Will check why this happens.
Same issue as #181811, but only the editing part was fixed with #181811. This instance occurs on MusicXML import.
Fixed file attached.
Simple test file attached. Issue is still present in latest 2.2 (commit 072c135) and in master (as of commit 6fbf7279).
In reply to (No subject) by Jojo-Schmitz
Analysis:
The MusicXML importer calls Part::setLongName(const QString& s) with s unmodified as read from the MusicXML part-name element. Thus s can contain any character. Via Instrument::setLongName(const QString& f) this calls StaffName(const QString& s, int p=0), which sets StaffName::_name to s.
When writing in MuseScore format, StaffName::write(Xml& xml, const char* tag) calls Xml::writeXml(const QString& name, QString s) to write StaffName::_name, where the issue occurs as writeXml expects the string to be written to be already properly xml-escaped, which it is not in this case.
This could be fixed in the MusicXML importer, but I think the structural solution would be to enforce StaffName::_name to always be properly escaped text in the StaffName class. This means adding validation to the StaffName constructor. If we don't solve it this ways, all StaffName users must be checked / changed.
Opinions anyone ?
Came up again in https://musescore.org/en/node/271417
Not a regression in 2.3, but a bug in 2.1 and probably earlier
Came up once again in https://musescore.org/en/node/276683.
In master 3280e3574c the file attached in https://musescore.org/en/node/264712#comment-808095 crashes MuseScore when saving to mscz.
Pull request (against master): https://github.com/musescore/MuseScore/pull/4017. Solves the issue, no regression observed.
Cause of crash found, see #277029: [MusicXML import] Crash caused by unsupported QVariant, which I will fix shortly.
Fixed in branch master, commit 5cdc29ca4c
fix #264712 - [MusicXML import] incorrect handling of instrument name with ampersand
Fixed in branch master, commit 14cf1fbfc3
Merge pull request #4017 from lvinken/276683-xml-error
fix #264712 - [MusicXML import] incorrect handling of instrument name…
Automatically closed -- issue fixed for 2 weeks with no activity.