Adding Code Blocks causes 404 error when saving #5581

Open
opened 2026-02-05 10:11:01 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @clementvc on GitHub (Jan 27, 2026).

Describe the Bug

I'm trying to document several small snippets of JavaScript and CSS. Placing these in code blocks, then trying to save, causes BookStack to show a 404 error.

Steps to Reproduce

  1. Go to the three dots just to the right of the add image and select code [<>]
  2. insert code into code block (see code below)
  3. `
<script>   (function(d,t) {     var BASE_URL="https://app.chatwoot.com";     var g=d.createElement(t),s=d.getElementsByTagName(t)[0];     g.src=BASE_URL+"/packs/js/sdk.js";     g.async = true;     s.parentNode.insertBefore(g,s);     g.onload=function(){       window.chatwootSDK.run({         websiteToken: 'xxxxxxxxxxxxxxxxxxxxxx',         baseUrl: BASE_URL       })     }   })(document,"script"); </script>`
  1. Select "Save"
  2. Recieve a 4040 ferror

Expected Behaviour

Save the page

Screenshots or Additional Context

No response

Browser Details

Chrome 143.0.7499.193 (Official Build) (arm64)

Exact BookStack Version

BookStack v25.11.6

Originally created by @clementvc on GitHub (Jan 27, 2026). ### Describe the Bug I'm trying to document several small snippets of JavaScript and CSS. Placing these in code blocks, then trying to save, causes BookStack to show a 404 error. ### Steps to Reproduce 1. Go to the three dots just to the right of the add image and select code [<>] 2. insert code into code block (see code below) 3. `<link rel='stylesheet' id='dashicons-css' href='https://staging.whitelakestudios.com//wp-content/themes/extendable/assets/css/test.css' media='all' /> <script>   (function(d,t) {     var BASE_URL="https://app.chatwoot.com";     var g=d.createElement(t),s=d.getElementsByTagName(t)[0];     g.src=BASE_URL+"/packs/js/sdk.js";     g.async = true;     s.parentNode.insertBefore(g,s);     g.onload=function(){       window.chatwootSDK.run({         websiteToken: 'xxxxxxxxxxxxxxxxxxxxxx',         baseUrl: BASE_URL       })     }   })(document,"script"); </script>` 4. Select "Save" 5. Recieve a 4040 ferror ### Expected Behaviour Save the page ### Screenshots or Additional Context _No response_ ### Browser Details Chrome 143.0.7499.193 (Official Build) (arm64) ### Exact BookStack Version BookStack v25.11.6
OVERLORD added the 🐛 Bug label 2026-02-05 10:11:01 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jan 29, 2026):

Hi @clementvc,

  • Are you able to reproduce this on our demo instance?
  • Do you have any web-application-firewall (WAF) services in use with BookStack like Apache ModSecurity? Or are you using any security proxies like Cloudflare?
@ssddanbrown commented on GitHub (Jan 29, 2026): Hi @clementvc, - Are you able to reproduce this [on our demo instance](https://github.com/BookStackApp/BookStack/blob/5754acf2fb9fcb60bb2ffd95bab3b0bcb1b162fd/app/Entities/Models/Deletion.php#L19)? - Do you have any web-application-firewall (WAF) services in use with BookStack like Apache ModSecurity? Or are you using any security proxies like Cloudflare?
Author
Owner

@clementvc commented on GitHub (Jan 29, 2026):

Well, it works perfectly on the Demo instance. I checked, and ModSecurity was on. Turning it off did not fix the issue. It is installed on a shared hosting environment, so I can see that might cause issues.

@clementvc commented on GitHub (Jan 29, 2026): Well, it works perfectly on the Demo instance. I checked, and ModSecurity was on. Turning it off did not fix the issue. It is installed on a shared hosting environment, so I can see that might cause issues.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5581