duplicate bookmark will break include #1142

Closed
opened 2026-02-04 23:58:41 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @ezzra on GitHub (Apr 15, 2019).

When using copy&paste for texts and lists, it might happens that there are duplicate bookmarks on one page. When including anything from that page, this will produce a fatal error on the page with include template:

production.ERROR: DOMDocument::loadHTML(): ID bkmrk-xxx-%28 already defined in Entity, line: 45 {"userId":x,"email":"xx@xx","exception":"[object] (ErrorException(code: 0): DOMDocument::loadHTML(): ID bkmrk-xxx-%28 already defined in Entity, line: 45 at /var/www/xx/bookstack/app/Entities/Repos/EntityRepo.php:664)

Reproduce
Create a page A with duplicate bookmarks, like <ul id="bkmrk-xxx-%28"></ul> <ul id="bkmrk-xxx-%28"></ul>. This page will still work. But if you include something from that page within page B, B will return an error.

Originally created by @ezzra on GitHub (Apr 15, 2019). When using copy&paste for texts and lists, it might happens that there are duplicate bookmarks on one page. When including anything from that page, this will produce a fatal error on the page with include template: `production.ERROR: DOMDocument::loadHTML(): ID bkmrk-xxx-%28 already defined in Entity, line: 45 {"userId":x,"email":"xx@xx","exception":"[object] (ErrorException(code: 0): DOMDocument::loadHTML(): ID bkmrk-xxx-%28 already defined in Entity, line: 45 at /var/www/xx/bookstack/app/Entities/Repos/EntityRepo.php:664) ` **Reproduce** Create a page A with duplicate bookmarks, like `<ul id="bkmrk-xxx-%28"></ul> <ul id="bkmrk-xxx-%28"></ul>`. This page will still work. But if you include something from that page within page B, B will return an error.
OVERLORD added the 🐛 Bug label 2026-02-04 23:58:41 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Apr 15, 2019):

Thanks for reporting @ezzra, Can confirm the issue.
I have made an update in c380c10d54, along with a test to cover, to prevent the page hard-failing and instead still render but without the included content.

I'll keep this open as it'll be good to update the logic on save to de-dupe any ids.

@ssddanbrown commented on GitHub (Apr 15, 2019): Thanks for reporting @ezzra, Can confirm the issue. I have made an update in c380c10d54b96ae3f2f4c1c4ba7fbf1822f3b945, along with a test to cover, to prevent the page hard-failing and instead still render but without the included content. I'll keep this open as it'll be good to update the logic on save to de-dupe any ids.
Author
Owner

@ssddanbrown commented on GitHub (Apr 20, 2019):

Hi @ezzra,
Can you confirm the editor and/or process you're following to save the content with duplicate ID's?

Just been digging into the content saving logic and found there's already code in place to de-dupe bkmrk ids. Having exact steps/content for replicating this would really help.

@ssddanbrown commented on GitHub (Apr 20, 2019): Hi @ezzra, Can you confirm the editor and/or process you're following to save the content with duplicate ID's? Just been digging into the content saving logic and found there's already code in place to de-dupe bkmrk ids. Having exact steps/content for replicating this would really help.
Author
Owner

@ezzra commented on GitHub (Apr 21, 2019):

It looks like it can happen with nested lists:


<ul id="bkmrk-eins-zwei-drei">
<li>eins</li>
<li>zwei</li>
<li>drei</li>
<ul id="bkmrk-eins-zwei-drei">
<li>eins</li>
<li>zwei</li>
<li>drei</li>
</ul>
</ul>

Code like that was a result from copy&pasting I think.

@ezzra commented on GitHub (Apr 21, 2019): It looks like it can happen with nested lists: ``` <ul id="bkmrk-eins-zwei-drei"> <li>eins</li> <li>zwei</li> <li>drei</li> <ul id="bkmrk-eins-zwei-drei"> <li>eins</li> <li>zwei</li> <li>drei</li> </ul> </ul> ``` Code like that was a result from copy&pasting I think.
Author
Owner

@ssddanbrown commented on GitHub (Apr 21, 2019):

Thanks for confirming, Could now replicate. I've added logic to de-dupe ID's on all child elements to prevent such occurrences persisting after saving.

@ssddanbrown commented on GitHub (Apr 21, 2019): Thanks for confirming, Could now replicate. I've added logic to de-dupe ID's on all child elements to prevent such occurrences persisting after saving.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1142