surveyjs-wordpress icon indicating copy to clipboard operation
surveyjs-wordpress copied to clipboard

HTML questions are ending up as plain text

Open flowt-au opened this issue 6 years ago • 6 comments

If I have this in my survey JSON:

{
    "type": "html",
    "name": "question1",
    "html": "<h4>Welcome!</h4>"
}

the resulting html in the survey is:

<div data-bind="html: question.locHtml.koRenderedHtml">Welcome!</div>

i.e. no html tags. I am assuming WP is doing that? Not sure what to do.

Any ideas? Thanks, Murray

flowt-au avatar Dec 03 '18 22:12 flowt-au

The survey JSON is sanitized on save into WP database (https://github.com/surveyjs/surveyjs-wordpress/blob/master/ajax_handlers/save_survey.php#L14) in order to cut off potentially malicious content

This was the requirement from WP guys before they approved this plugin

It looks like this sanitization kills the html question content.

We'll check whether we can use less strict sanitization function.

In any case you can use any other sanitization function in your local WP instance - just patch this line of code

tsv2013 avatar Dec 05 '18 07:12 tsv2013

Ok. Thanks. What if the plugin was set up with a Markdown hook? That way the save sanitisation wouldn't change the content and the simple things like bold and links could be formatted on viewing?

Just a thought for later. Thanks, Murray

flowt-au avatar Dec 05 '18 08:12 flowt-au

@flowt-au Thank you for sharing your thoughts and feedback. It is very helpful. SurveyJS library does have markdown hook. We'll consider to use it in the plugin.

tsv2013 avatar Dec 05 '18 08:12 tsv2013

Happy to help. It is a great product!

flowt-au avatar Dec 05 '18 08:12 flowt-au

I'm looking to see if there is an update on this, or a potential workaround that would allow the html content to be maintained? I am dealing with this issue right now.

slatecake avatar Jul 09 '19 14:07 slatecake

@slatecake This behavior is so due to sanitization of the all texts passed to wordpress server. This was requirement during SurveyJS wordpress plugin approvement. You can change this behavior on your custom wordpress installation. But be aware of security vulnerabilities.

tsv2013 avatar Jul 09 '19 14:07 tsv2013