Fix underscores and escaping in menu labels#2355
Open
ztlxltl wants to merge 1 commit into
Open
Conversation
Member
|
Did you intend this to target the gramps61 branch? |
Contributor
Author
|
I wasn't sure which version this bug should ideally be fixed in. I'm happy to change it if you prefer 6.1. |
b80e956 to
a1ccfbd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the display of underscores in the menu, especially for user-defined names, like database or tag names.
In GTK, an underscore in menu labels is used to mark the following letter as keyboard accelerator called a mnemonic. The letter appears underlined, or becomes underlined when pressing the
Altkey. In case the user defines a database name or a tag name that includes an underscore, the underscore will not be shown in the menu. By using.replace("_", "__"), the underscore is escaped so it will appear in the menu. The same applies for bookmarked people with an underscore in their formatted name (e.g. many names in theroyal92.ged).While checking other custom strings in the menu, I also noticed that plugin names used in the Reports and Tools menus are not escaped using
html.escape()orxml.sax.saxutils.escape. While I don't know a plugin name that requires this, devs of new plugins could have a hard time debugging the resulting error message.I also saw that less thorough cleaning up of plugin IDs happens when handling "unsupported items" in
ViewManager.build_plugin_menu(). I'm not sure what those unsupported items can be, but from my limited understanding their IDs have a similar risk of having invalid chars as the IDs of other plugins. I wasn't able to test this, so I would appreciate it if someone who has more knowledge of this part could have a closer look.In summary, this PR does the following:
.replace("_", "__")html.escape()and.replace("_", "__"))valid_action_name().replace("_", "__").replace("_", "__"))