Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chris Mahoney 242 posts 454 karma points
    Jul 19, 2023 @ 23:37
    Chris Mahoney
    0

    Block base64 in RTE?

    Hi everyone,

    Is there a way to prevent saving of base64 images in the rich text editor? Sometimes editors will (presumably) just paste an image into the RTE, and this results in <img src="data:image/png;base64... in the resulting HTML and ultimately triggers this issue.

    Is there some way I can block base64 saving to prevent this from happening in the future?

    I'm running Umbraco 10.6.1.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Jul 21, 2023 @ 10:30
    Huw Reddick
    0

    I don't believe that is what happens when you paste in an image, definitely not on my U10 instance, when you first paste in an image this gets written to the RTE <img src="blob:https://localhost:44316/92bab7d7-90f6-40b5-a173-501f4210e57a" alt="" width="364" height="261" data-tmpimg="~\umbraco\Data\TEMP\FileUploads\rte\56f2a9ab-cc2a-46f8-a2e4-7f589080b7f8\image.png" /> when you then save it would seem it gets uploaded to media as <img src="/media/bbcpn4nz/image.png?rmode=max&amp;width=364&amp;height=261" alt="" width="364" height="261" data-udi="umb://media/f9e6450e7fb944318a873d16bf69a4ba" />

  • Chris Mahoney 242 posts 454 karma points
    Jul 23, 2023 @ 20:31
    Chris Mahoney
    0

    OK, maybe the editors are doing something else, or there's a strange incompatibility here. However, base64-encoded data is still appearing in the HTML. I'm not really worried about how it originally gets in there, as long as it can't be saved.

    Can something be done in the TinyMCE configuration to prevent this?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Jul 24, 2023 @ 08:06
    Huw Reddick
    0

    You would probably need to create a notification handler when saving and then maybe use some regex to strip out image tags with base64 in the src attribute

  • Chris Mahoney 242 posts 454 karma points
    Aug 01, 2023 @ 20:46
    Chris Mahoney
    0

    I've found someone else with the same issue and there's a comment on there that "Tiny MCE 4.x has a new option to prevent data URIs." That would be much easier than writing a custom handler/regex, but unfortunately there's no further detail on where to find this feature.

    It appears that it might be paste data images. However, I've yet to replicate the base64 behaviour myself, and the "offending" editor seems to have been out of the office all week, so I haven't been able to actually test this.

    In short, I'm not ignoring you, but just don't really have anything else to say yet.

Please Sign in or register to post replies

Write your reply to:

Draft