mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-05 00:29:48 +03:00
Pages not rendering base64 blob images #2152
Closed
opened 2026-02-05 03:07:31 +03:00 by OVERLORD
·
12 comments
No Branch/Tag Specified
development
l10n_development
further_theme_development
release
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
No Label
🔍 Pending Validation
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#2152
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @awarre on GitHub (Mar 11, 2021).
Describe the bug
Pages not rendering images after pasting images into WYSIWYG editor when original source is a base64 image blob.
Steps To Reproduce
Steps to reproduce the behavior:
Expected Behavior
The image should render both on the editor, and on the actual page.
More info
This is very close to working. The image does get uploaded, and can be accessed directly and viewed through the editor. The path generated is in the format of:
blob:https://example.com/aabb1234-1234-aabb-bbcc-ffffeeeeffff. As stated above, this is the expected uploaded image and can be accessed directly.It appears the page does not generate the
element at all. If it did, everything should work as expected.
Your Configuration (please complete the following information):
@ssddanbrown commented on GitHub (Mar 12, 2021):
Thanks for reporting @awarre with the provided detail.
Just tried this in the WYSIWYG and markdown editors on my local instance using the same image and in both instances the image data uploaded into BookStack as expected. On Firefox/Fedora.
Could you confirm the browser in use when this occurs?
@awarre commented on GitHub (Mar 12, 2021):
Using the latest build of Chrome on Windows 10. I just tested with Edge and see the same (though that's not much of a difference).
I can replicate this issue on the BookStack Demo site as well. It doesn't look like a browser rendering issue, because the
<img>element is entirely missing from the page.Where the empty
<p>tags are, there should be the image.@awarre commented on GitHub (Mar 12, 2021):
The Editor page shows the code below, and the image is correctly rendered.
@awarre commented on GitHub (Mar 12, 2021):
Verified the same results with latest release of Firefox on Windows as well, using the BookStack Demo site, with the image copy and pasted from the website listed above.
@awarre commented on GitHub (Mar 12, 2021):
Okay, sorry for so many updates, just trying to get a minimal process to reproduce this. You do not need to copy and paste the image itself to reproduce the problem.
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM0AAAD NCAMAAAAsYgRbAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5c cllPAAAABJQTFRF3NSmzMewPxIG//ncJEJsldTou1jHgAAAARBJREFUeNrs2EEK gCAQBVDLuv+V20dENbMY831wKz4Y/VHb/5RGQ0NDQ0NDQ0NDQ0NDQ0NDQ 0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0PzMWtyaGhoaGhoaGhoaGhoaGhoxtb0QGho aGhoaGhoaGhoaGhoaMbRLEvv50VTQ9OTQ5OpyZ01GpM2g0bfmDQaL7S+ofFC6x v3ZpxJiywakzbvd9r3RWPS9I2+MWk0+kbf0Hih9Y17U0nTHibrDDQ0NDQ0NDQ0 NDQ0NDQ0NTXbRSL/AK72o6GhoaGhoRlL8951vwsNDQ0NDQ1NDc0WyHtDTEhD Q0NDQ0NTS5MdGhoaGhoaGhoaGhoaGhoaGhoaGhoaGposzSHAAErMwwQ2HwRQ AAAAAElFTkSuQmCC" alt="beastie.png">Result
@awarre commented on GitHub (Mar 19, 2021):
@ssddanbrown
Source of the problem is PageContent.php, line 348.
It looks like the intent of the code was to remove iframes, but the query matches
<img>elements withdata:as well.I've verified the content is correctly saved to the database, but the rendering process is sanitizing it and preventing the images from showing.
@awarre commented on GitHub (Mar 20, 2021):
I am not familiar with PHP xpath syntax, but maybe this line would meet the security concerns as well as allowing blob images?
@ssddanbrown commented on GitHub (Mar 20, 2021):
Thanks for digging into this and offering a pull request @awarre.
To be honest though, I don't really want to be handling base64 image data or blob types within the content, these should be stored as images. Even if we merged your changes I don't think it will solve your original case since they enter the editor as a blob, not base64.
Ideally we'd need to properly handle pasting with mixed content that includes images but it might touch upon the difficulties of #449 unless things have improved since I last checked. Content pasting formats seem to be a constant moving target.
@awarre commented on GitHub (Mar 20, 2021):
I've confirmed in my test environment it did resolve. The database is storing this to the
htmlfield the following data:Obviously your call if you don't like this solution. I was just trying to find the cause and a solution that works to resolve my problem with rendering the data as it was being stored.
@ssddanbrown commented on GitHub (Mar 20, 2021):
@awarre Ah, I get you now, the browser converting the blobs on send.
I'm going to close the PR, as I don't want to get into storing base64 images within the database since it's had some impacts (mainly due to large content sizes) when it's leaked in before. But we'll leave this open with the intention if ideally reading out the blobs and storing into the system.
For web images like this, They should be handled properly if you right-click>"Copy Image" and then paste into BookStack. It's just when a large amount of content gets mixed in which causes complications.
@awarre commented on GitHub (Mar 20, 2021):
Got it. This is a bit of an artificial scenario I created to narrow down the source of a problem I encountered in the real world.
My issue involved trying to import data from another knowledge management system into BookStack. Whether exported to CSV/JSON via their API, raw database data, or manually copying and pasting the entire document from the rendered web page. When another system does support base64 image storage, I see no clear method to get it into BookStack without a lot of manual effort.
Manually copy and pasting individual images from thousands of documents won't be very practical, so I guess I'll just have to find an alternative solution.
@ssddanbrown commented on GitHub (Jun 2, 2021):
Closing as per #2700, Will be part of the next patch release.