Ampersand character and any subsequent characters are not displayed in Staff Name

• Sep 16, 2014 - 12:05
Type
Functional
Severity
S2 - Critical
Status
closed
Project

1. Open any score. (If it is a single stave system uncheck the option to hide the staff name)
2. Open Staff Properties dialogue
3. Change name to Trombones 1 & 2
4. OK or Apply

Expected resulted: Staff Name dispalys as Trombones 1 & 2
Actual Result: Staff Name displays as Trombones 1

See screen shot

pic

Windows 8.1 Pro
MuseScore 2.0 beta

Attachment Size
Staff name bug.png 93.66 KB

Comments

This seems to be an unfortunate side effect of the change to use HTML-style markup here. "&" is a special character. We might need to tweak our parsing of the text to not be fooled by "regular" uses of "&".

Meanwhile, the workaround is to use the HTML markup for ampersand: "&"

Yes I was expecting it to be something like that.

If we use the markup version. How will that affect display when the problem is fixed?

I'm currently working on more default templates and I don't want to end up with ones that display as Trombones 1 "&" 2 or Trombones 1 "&amp" 2

I guess the issue tracker ate my markup :-)

No idea what the real solution will be, so I guess I'd hold off on this aspect of the templates for now if I were you.

If the staff names are supposed to use HTML format, then the staff properties dialog should use the QTextEdit class for editing them to allow for rich text editing capabilities, shouldn't it? Currently the names are just in plain text boxes which don't filter out/escape characters like ampersand which have special meaning in html. Besides a potential for making a score unreadable, this means in theory someone might be able to inject code into them (a security risk)

Actually, it looks like the edit boxes for instrument names in editstaff.ui are already QTextEdit fields. We need to escape HTML special characters like ampersand into their appropriate HTML entities. Not sure why the QTextEdit class doesn't handle this escaping automatically.

Instrument names are entered in a html like syntax like header or footer text.
This makes inputting special symbols like b or # easy.
If we want allow this, then "&" has to be entered as "&". If we interpret the text box contents as verbatim text, then MuseScore can escape it internally but we loose the ability to enter any rich text.

The list of char's to escape:
"<" -> "&lt;"
">" -> "&gt;"
"&" -> "&amp;"
" -> "&quot;"

Using a WYSIWYG editor is too expensive to implement and postponed for a later version.

OK, but is there something we can do to either a score from being written that won't be able to be read? Either do a special check for unescaped characters when the dialog is processed and replace them, or else do the same on read of the file? Quotes and angle brackets might not be all that common in instrument names, but the ampersand kind of is.

We need to validate the HTML entered by the user. When the '&' symbol is used in an instrument name, it is interpreted as invalid HTML markup which breaks the score.

Title Ampersand character and any subsequent characters are not displayed in Staff Name Ampersand character and any subsequent characters are not displayed in certain types of text
Status (old) closed active

"A single '&' is automatically fixed"—not in all circumstances. Part names and copyright both still exhibit the exact same behavior ChurchOrganist described. This is not totally fixed yet.