Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML questions are ending up as plain text #7

Open
flowt-au opened this issue Dec 3, 2018 · 6 comments
Open

HTML questions are ending up as plain text #7

flowt-au opened this issue Dec 3, 2018 · 6 comments
Labels
question Further information is requested

Comments

@flowt-au
Copy link

flowt-au commented Dec 3, 2018

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

@tsv2013
Copy link
Member

tsv2013 commented Dec 5, 2018

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 tsv2013 added the question Further information is requested label Dec 5, 2018
@flowt-au
Copy link
Author

flowt-au commented Dec 5, 2018

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

@tsv2013
Copy link
Member

tsv2013 commented Dec 5, 2018

@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.

@flowt-au
Copy link
Author

flowt-au commented Dec 5, 2018

Happy to help. It is a great product!

@slatecake
Copy link

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.

@tsv2013
Copy link
Member

tsv2013 commented Jul 9, 2019

@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.

selestos added a commit to selestos/surveyjs-wordpress that referenced this issue Aug 6, 2020
tsv2013 added a commit that referenced this issue Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants