We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Filter String - request post

Hi guys,

I have the following string: "<p> Test Test </p>", when I recover in $this-> request-> get ('field', 'string'); I lose the html tags, would like to keep, I was looking for filter.zep, it seems to have implemented this filter.

thank you!

echo htmlentities($this->request->get('field', 'string'));
// Test Test

echo htmlentities($this->request->get('field'));
// <p> Test Test </p>

Have tou tried removing the "string" filter? Also you could get confused when printing html in the browser because it gets rendered?

then receives data from a js editor (editor-alloy), and need to save the tags in the database, but my other concern is the XSS. I do not know if the htmlentities solve.

Vanilla PHP still works, so you could possibly use $_POST or $_GET



79.0k
Accepted
answer

If you really need to pass HTML formatted strings via HTTP GET, you can base64 encode them before sending (in your AJAX/JS). Then just base64 decode it on PHP/Phalcon.