Stop Drupal From Stripping Out Code
Code can be dangerous. The right code in the right place brings your site to life, but there are many places where it can be a huge security risk.
Inside your content, code can be dangerous. If you allow people to use PHP, Javascript, iframes or other code inside content, you greatly increase the chances of a malicious script being used.
To minimize this risk, by default Drupal restricts the code you can use in content.
The downside to this is that some common code isn’t allowed. For example, most HTML is blocked by default. Here’s how to allow those on your site by stopping Drupal from stripping out code.
Text Formats
By default, Drupal content is entered as “Filtered HTML”. What does that mean? Drupal explains in the image above.
- Web page addresses and e-mail addresses turn into links automatically.
- There are only twelve allowed HTML tags.
Click on the dropdown link and you’ll get extra options:
Full HTML is described in this way:
- Web page addresses and e-mail addresses turn into links automatically.
- Lines and paragraphs break automatically.
Plain text is described in this way:
- No HTML tags allowed.
- Web page addresses and e-mail addresses turn into links automatically.
- Lines and paragraphs break automatically.
You can also to the Modules page and enable PHP filter:
This is described more simply:
- You may post PHP code. You should include tags.
How does this impact your content?
Let’s see an example of how text filters impact your content. In this example we’re adding a Google Map to our content.
If we save this page with Filtered HTML, the end result will look like the image below.
If we save this page with Full HTML, the end result will look like the image below.
Modifying the Text Filters
If the default settings aren’t right for you, go to Configuration > Text format.
You’ll see that different filters are set up for different user groups. For security reasons, anonymous users and authenticated users only get access to Filtered HTML.
Click on Configure next to any text filter to change the options:
It is much helpful article about stop Drupal from stripping out code. Your blog is having interesting topic as compared to other article on the web. Please can you help me, how to set cookies in PHP?
Good explanation has been given for learning about Drupal. I think it is a good approach. Thank you, keep up with your work don’t leave it.
Hi! Thanks a lot for sharing such nice stuff regarding responsive web design drupal.This is what makes the Drupal community best so far.Great write – up. Cheers!
excellent article on using right content at the right place. Your post is very useful to new and experienced PHP developer.
I recommend your article to my friends and students.
PHP
training in Chennai
It looks very interesting, I am willing to read this post and give good appreciation to the author. I’m from Indonesia happy to visit here. Thank you.
Thank you Steve. The text format changes are very useful. I can use it input a table into my map info window like this:
Great, that’s good to hear
Sorry but using the PHP filter is a horrible idea.
I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
https://www.besanttechnologies.com/training-courses/data-warehousing-training/hadoop-training-institute-in-chennai
in text format of php how to include html tags
Good work.
Hi
good one, thanks
this helped thanks
I enjoyed your post
keetp it up
Informative article. I was searching for this information on google.
It looks very interesting, I am willing to read this post and give good appreciation to the author. I’m from Indonesia happy to visit here. Thank you.
nice
Hello, steve! Thank you for this blog about Drupal and codes. I’m also grateful for how you point out how dangerous it can be if not handled in a way to minimize its risk.
nice information, thanks