<p>You've probably got "Purify HTML" checked under your Rich Text field's settings and that's stripping code.</p>

<p>You should really only have that checked if you're accepting input from untrusted sources using the Rich Text field on the front-end of your site. Presumably all users using the control panel are trusted enough not to input malicious code into the site.</p>

CC BY-SA 3.0
2016-03-02T11:37:01.923Z
Depends where they're copy-pasting the content from. The amount of times our clients just copy from a website or PDF and ended up with mangled code in the Entry... I could see someone copying a JS worm accidentally.

We now have Purify on all the time. Far less issues.
Matt Wilcox
CC BY-SA 3.0
2016-03-01T23:36:39.053Z
2016-03-01T23:36:39.053Z
Brad Bell
<p>In one of the Rich Text Fields I'm entering little snippets like this:</p>

<pre><code>&lt;pre&gt;
&lt;code class="language-css"&gt;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility !important;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, .004);
&lt;/code&gt;
&lt;/pre&gt;
</code></pre>

<p>However, each time i edit again it removes the value although when i save it the first time its ok. I think its converting at edit time.</p>

<p>Is there anyway to prevent redactor from doing this?</p>

<entries><redactor>
Prevent Rich Text editor from removing code tags?
# Prevent Rich Text editor from removing code tags?

(Asked by: username_0 on 2016-03-01)

In one of the Rich Text Fields I'm entering little snippets like this:


  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility !important;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, .004);



However, each time i edit again it removes the value although when i save it the first time its ok. I think its converting at edit time.
Is there anyway to prevent redactor from doing this?

**Tags:** entries, redactor


---

## 1 answers

### Answer by username_1 on 2016-03-01. Score: 3

You've probably got "Purify HTML" checked under your Rich Text field's settings and that's stripping code.

You should really only have that checked if you're accepting input from untrusted sources using the Rich Text field on the front-end of your site. Presumably all users using the control panel are trusted enough not to input malicious code into the site.

> **Comments:**
> **username_2**: Depends where they're copy-pasting the content from. The amount of times our clients just copy from a website or PDF and ended up with mangled code in the Entry... I could see someone copying a JS worm accidentally.  We now have Purify on all the time. Far less issues.  

---

