Question: WText inline image without UnsafeXHTML ?
I am trying to insert into WText widget inlined image, like
<span style="display:inline-block;"> <img> </img> </span>
but it happens to work only with UnsafeXHTML
As long as data provided for the widget comes from various sources, i do want benefit from safe variant, avoiding dangerous scripts running.
Is there a way to make it in an alternative safe manner, staying simple at the same time (not writing own parser to insert layout widgets etc) ?
Or is there a chance img directive will be moved to safe side, just like span, and parsed dirrectly from the text ?
Updated by Andrii Zhuk over 2 years ago
Korneel Dumon wrote in #note-1:
I think you need
WTemplate, there you can put images in the text. Then you can use
WTemplate::bindStringto bind any text that should be filtered.
Another way to add an image to a page is to use
Thank you Korneel,
WImageas widget) did the trick.
Was a little bit stuck on thw way how template is created and operates. So for someone else:
- see https://www.webtoolkit.eu/widgets/layout/html-templates for example
WTemplate::setTemplateTextto set template string (https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WTemplate.html)
WTemplate::bindWidgetto insert your needed code or widget
- the best thing about
WTemplate::setTemplateTextis marked as
TextFormat::XHTML, but inserted parts may be
TextFormat::UnsafeXHTML, just what I needed