Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:33:24+00:00 2026-06-01T01:33:24+00:00

I have the following example of what a user might type into a field

  • 0

I have the following example of what a user might type into a field for a post name:

<h1><span>They're awesome people</span></h1>

Now because this is a post title I want to remove all that HTML completely before saving it to the database. This is because for a) security reasons and b) if I export this as JSON I don’t want to be cleaning up HTML on output for 3rd party users.

I have tried the following in my model:

public function beforeSave() {

        if (isset($this->data[$this->alias]['title']))
        {
            //$this->data[$this->alias]['title'] = Sanitize::clean($this->data[$this->alias]['title'], array('encode'=>true,'remove_html'=>true));

            $this->data[$this->alias]['title'] = html_entity_decode(Sanitize::html($this->data[$this->alias]['title'], array('remove'=>true)));
        }
        return true;

    }

As you can see I have tried both Clean and HTML from the Sanitize class to clean out the HTML but both cause a problem in that they escape the quote from they're making it like &#039;. I have tried using the html_entity_decode around the sanitize to clean this up but it still happens. Any ideas on how to do this?

If I do this though:

echo html_entity_decode('They&#039;re awesome people');

it works fine so the function is fine, it’s a problem with using it in conjunction with the sanitize class in CakePHP.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:33:26+00:00Added an answer on June 1, 2026 at 1:33 am

    Why not use

     Sanitize::paranoid() 
    

    Manual

    Or even strip_tags

    To make Sanitize::html work

    Sanitize::html($var, array('remove'=>true, 'quotes' => ENT_NOQUOTES));
    

    it uses htmlentities internaly and default flag is set to ENT_QUOTES.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how XSLT process namespace prefixes and have following example:
We have the following example in node.js var http = require('http'); http.createServer(function(request, response) {
I have the following example code: $dataProvider = new CActiveDataProvider('firstTable', array('criteria' => array( 'select'
I have the following example, compiled in VS2005, warning level 4: int main(int argc,
I have the following example of reading from a buffered reader: while ((inputLine =
I have the following example in a SQL table Cust Group Sales A 1
If I have the following example file where each number is represents a byte
If I have the following: /* * example.h */ #ifndef EXAMPLE #define EXAMPLE #include
Let's have a following example: public class X { } public class Y {
imagine the following simple Models (example for simplicity reasons; in fact, we have MVVM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.