Skip to content

Fix underscores and escaping in menu labels#2355

Open
ztlxltl wants to merge 1 commit into
gramps-project:maintenance/gramps61from
ztlxltl:fix-underscore-menu-labels
Open

Fix underscores and escaping in menu labels#2355
ztlxltl wants to merge 1 commit into
gramps-project:maintenance/gramps61from
ztlxltl:fix-underscore-menu-labels

Conversation

@ztlxltl

@ztlxltl ztlxltl commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

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 Alt key. 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 the royal92.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() or xml.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:

  • Recent databases: add .replace("_", "__")
  • Reports and Tools menus: add html.escape() and .replace("_", "__"))
    • For "unsupported" items: additionally add valid_action_name()
  • Bookmarks: add .replace("_", "__")
  • Tags: add .replace("_", "__"))

@Nick-Hall

Nick-Hall commented Jun 6, 2026

Copy link
Copy Markdown
Member

Did you intend this to target the gramps61 branch?

@ztlxltl

ztlxltl commented Jun 6, 2026

Copy link
Copy Markdown
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.

@ztlxltl ztlxltl force-pushed the fix-underscore-menu-labels branch from b80e956 to a1ccfbd Compare June 7, 2026 06:28
@ztlxltl ztlxltl changed the base branch from master to maintenance/gramps61 June 7, 2026 06:29
@Nick-Hall Nick-Hall added Status: Pending A pull request that is pending review. and removed Status: New labels Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Pending A pull request that is pending review. Type: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants