eeditiones / tei-publisher-app

The main TEI Publisher app
https://teipublisher.com
GNU General Public License v3.0
68 stars 33 forks source link

`id` parameter should be stripped from link URLs when target element lacks `xml:id` attribute #92

Open joewiz opened 2 years ago

joewiz commented 2 years ago

When I navigate from https://teipublisher.com/exist/apps/tei-publisher/doc/documentation.xml?odd=docbook.odd&id=web-annotations (“Annotating Documents”) to the next chapter (“Configuring the Annotation Editor”) using the TOC in the left sidebar, the root parameter is updated, but the id parameter is not. As a result, if I reload the page, I’m returned to “Annotating Documents” instead of the expected page (“Configuring the Annotation Editor”).

As a result of this bug, if a user shares a URL to a place in the documentation, the recipient may end up on the wrong page.

Looking at the source for documentation.xml, I see some sections (like “Annotating Documents”) have @xml:id attributes, but others (like “Configuring the Annotation Editor”) don’t. The application seems to update the id parameter in the URL if the selected section has an xml:id attribute, but they leave any existing id in place if the selected section does not have an xml:id attribute, instead of stripping the id parameter and letting the root parameter serve as the address for the target element. (When a request contains both an id parameter and a root parameter, TEI Publisher only considers the id parameter.)

As a workaround for this specific report, we could simply add xml:id attributes to all section elements, but it seems that the application should handle this scenario more gracefully: the id parameter should be stripped from link URLs when the target element lacks an xml:id attribute.