GNOME Bugzilla – Bug 663019
bookmark name cannot include a '&'
Last modified: 2015-10-16 13:08:18 UTC
Putting a '&' in a bookmark name causes it to pick up the name of the bookmark before it. Expected behaviour: - Bookmark name gets set as typed
I've noticed this too.
with evince 3.16 including an ampersand in the bookmark label produces this error: (gv:3092): Gtk-WARNING **: Failed to set text from markup due to error parsing markup: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity - escape ampersand as & and the bookmark is not set. Using "&" instead of "&" in the bookmark label works.
I have the same problem in evince 3.14.2. Here is an example: Open the following file in evince: https://www.gnome.org//wp-content/uploads/2014/09/GNOME-Annual-Report-2013.pdf In the sidebar, go to the Bookmarks section. On page 1, click Add to add a new bookmark. By default it will be named "Page 1". Rename the bookmark to "&". After pressing Enter, notice that the name returns to "Page 1". "Add" a bookmark on page 2. Notice that while the new bookmark is named "Page 2", the old one gets renamed "Page 2" too. "Add" a bookmark on page 3. Notice that the real "Page 2" keeps its name, but the first one is renamed "Page 3". With the cursor, hover the first bookmark. Notice that it confuses its identity and switches between "Page 2" and "Page 3". If you rename "Page 3" to "&", it will simply obtain the name of the previous bookmark, which in this case is "Page 2". That is all the behavior that I noticed when using "&" in bookmarks.
It seems that when placing the "&" character as a bookmark title in the "markup" property of the GtkCellRendererText, it gets recognized as a malformed special entity such as ", &, <, and >. I don't think we want any complex styling/formatting as bookmark titles. A simple solution is to place the bookmark title on the regular "text" property of the cell renderer, as proposed in the patch below.
Created attachment 310903 [details] [review] shell: use "text" cell renderer for bookmarks sidebar We don't need the advantages of using the "markup" property for the bookmarks sidebar. Besides, using "markup" limits the scope of characters the user can have in a bookmark title. Characters such "&" get recognized as malformed special entities such as ", &, <, and >.
Review of attachment 310903 [details] [review]: Looking the history of shell/ev-sidebar-bookmarks.c it seems the page number used to be entered as a markup (<i>%d</i>), which does not happen any more since a while (2010). The patch makes sense to me and it could be in the next stable release. Carlos? José? Christian?
*** Bug 756429 has been marked as a duplicate of this bug. ***
Created attachment 313252 [details] [review] shell: Escape bookmark title Since we are using a GMarkup rendered for the title, we need to escape text so characters like & will be correctly rendered by the TextView.
Review of attachment 313252 [details] [review]: It looks ok to me.
Ok. Commited at https://git.gnome.org/browse/evince/commit/?id=e0014008dc388708380560e4b7a10146866146c4