[Bug Report]: Erratic pasted code content behavoiour upon page save #2549

Closed
opened 2026-02-05 04:29:00 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @noxtras on GitHub (Dec 30, 2021).

Describe the Bug

When pasting text from a html pre element (like code samples), the editor goes berserk. It shows everything correctly, but when saving the page, it asks if I'm sure I want to navigate away. If I click yes, the page is saved, but all the other code blocks on the page get doubled somehow: each line in the other code samples becomes a separate code block inside it's main code block...

Steps to Reproduce

  1. Copy a code sample from https://kinsta.com/blog/xmlrpc-php/, but any text inside a pre is the same, from what I've tested.
  2. create a document in bookstack and add a code block with a few lines, save
  3. Paste inside the created page (that already has a code block). (The new code block you add after the existing block(s), on an empty white space.)
  4. Click save.

Expected Behaviour

either copy as text (clean all formatting) or insert as code block

Screenshots or Additional Context

No response

Exact BookStack Version

21.10.3

PHP Version

7.4

Hosting Environment

Ubuntu 20.4 LTS, Apache + Nginx

Originally created by @noxtras on GitHub (Dec 30, 2021). ### Describe the Bug When pasting text from a html pre element (like code samples), the editor goes berserk. It shows everything correctly, but when saving the page, it asks if I'm sure I want to navigate away. If I click yes, the page is saved, but all the other code blocks on the page get doubled somehow: each line in the other code samples becomes a separate code block inside it's main code block... ### Steps to Reproduce 1. Copy a code sample from https://kinsta.com/blog/xmlrpc-php/, but any text inside a pre is the same, from what I've tested. 2. create a document in bookstack and add a code block with a few lines, save 3. Paste inside the created page (that already has a code block). (The new code block you add after the existing block(s), on an empty white space.) 2. Click save. ### Expected Behaviour either copy as text (clean all formatting) or insert as code block ### Screenshots or Additional Context _No response_ ### Exact BookStack Version 21.10.3 ### PHP Version 7.4 ### Hosting Environment Ubuntu 20.4 LTS, Apache + Nginx
OVERLORD added the 🐛 Bug label 2026-02-05 04:29:00 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jan 4, 2022):

Thanks for reporting @noxtras.
This has been patched to be part of v21.12.1.

This wasn't caused by any pre blocks, but code blocks on other sites, with certain formatting, could confuse and break our parsing logic which would then break the editor. The patch adds more extensive and safer language parsing.

@ssddanbrown commented on GitHub (Jan 4, 2022): Thanks for reporting @noxtras. This has been patched to be part of v21.12.1. This wasn't caused by any pre blocks, but code blocks on other sites, with certain formatting, could confuse and break our parsing logic which would then break the editor. The patch adds more extensive and safer language parsing.
Author
Owner

@noxtras commented on GitHub (Jan 4, 2022):

super

@noxtras commented on GitHub (Jan 4, 2022): super
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2549