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 6073339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:15:37+00:00 2026-05-23T10:15:37+00:00

I have a form built with SafeCracker in ExpressionEngine. One of the textarea fields

  • 0

I have a form built with SafeCracker in ExpressionEngine. One of the textarea fields is used to allow users to submit HTML code.

Here’s an example of the type of code they will be providing:

<div style="left: 385px; top: 137px;" class="aaa"></div>.

When the form is submitted and the entry is saved to the database, SafeCracker strips out the inline CSS style. The result of what is actually saved to the database is:

<div class="aaa"></div>.

As you can see, the inline CSS style(s) are being removed but the rest of the HTML is maintained.

I want to allow users to be able to submit HTML code and not have SafeCracker strip out the inline CSS style(s). How can I accomplish this?

  • 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-05-23T10:15:37+00:00Added an answer on May 23, 2026 at 10:15 am

    SafeCracker uses the built-in ExpressionEngine XSS Sanitization Method to clean user submitted input from Cross Site Scripting (XSS) and SQL Injection vulnerabilities.

    Any front-side user input is sanitized by using $this->EE->security->xss_clean() before being inserted into the database or output to the screen.

    Thankfully for us, the Engineers at EllisLab have provided a secret, undocumented way of “whitelisting” fieldtypes and field_ids used in SafeCracker and exempting them from XSS filtering.

    To stop SafeCracker from stripping all HTML from a given field, open up the following file, depending on which version of ExpressionEngine you’re running:

    EE 2.1.3 or Earlier (SafeCracker installed as Third-Party Add-On)
    /system/expressionengine/third_party/safecracker/libraries/safecracker_lib.php


    EE 2.2.0 or Later (SafeCracker installed as First-Party Module)
    /system/expressionengine/modules/safecracker/libraries/safecracker_lib.php

    Note: ExpressionEngine 2.2.0 bundles SafeCracker as a first-party module, so your installation location will depend on what version you’re running or have upgraded from.

    Scroll down to around Line 2371 (for EE 2.1.3) or Line 2516 (for EE 2.2) and look for the following:

    $this->skip_xss_fieldtypes = array();
    $this->skip_xss_field_ids = array();
    

    Here’s where the fun begins. To “whitelist” a field from having the XSS Filter applied, simply add the fieldtype or field_id to either array.

    Here’s an example:

    $this->skip_xss_fieldtypes = array(
        // This is the fieldtype as specified in the Control Panel
        // Channel Fields, not what you use in your SafeCracker template
        'textarea'
    );
    $this->skip_xss_field_ids = array(
        // This is the field_id from the exp_channel_data MySQL Table
        'field_id_1'
    );
    

    You can either specify a certain type of fieldtype (textarea, input, etc.), or the field_id if you’d rather be more explicit. The former way is more general, while the latter is absolute and is more flexible if a custom field would to ever change its type.

    With these changes, any field(s) you exempt from the XSS Sanitization Method will no longer have any filtering applied, and allow any arbitrary HTML to be submitted into the database!

    Keep in mind, that any upgrades to ExpressionEngine may overwrite this file, so you may want to change the permissions on the file or keep a backup handy.

    Cross Site Scripting should be taken very seriously as you would never want your site to be the source of an attack vector. Always err on the side of caution.

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

Sidebar

Related Questions

I have a form which is built dynamically using this jQuery plugin http://code.google.com/p/jquery-dynamic-form/ When
I'm trying to have the action of a HTML form built when the user
I have an MVC view with a form built with the Ajax.BeginForm() helper method,
I have a form I am submitting via AJAX (using prototype and the built-in
I have the following situation: I built an Access form with a subform (which
In good old MFC, the DDX routines would have built in validation for form
I have a form like this: <form name=mine> <input type=text name=one> <input type=text name=two>
I currently have a form built in which after validation, if errors exist, the
I have a Windows Form application built on a data model and a Windows
I have a query building form built in PHP. The results of the query

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.