Solved

Store HTML Code in database and retrieve it, escaping &lt; as < ...

Posted on 2011-02-16
2
731 Views
Last Modified: 2012-05-11
Hi everybody.
 
    I am saving the contents of a textarea in a database. this textarea contains HTML tags.
 
    I pass the data using the POST Method using the function encodeURIComponent(). It is stored normally as %-escaped characters, but when I get the data again from the database, tags like <strong>SOMETHING</strong> becomes &lt;strong&gt;SOMETHING&lt;/strong&gt;
 
    What can I do to show the data as it was typed?
 
Thanks,
 
Thiago.
0
Comment
Question by:icefinges
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 250 total points
ID: 34912641
First of all, I hope you know about security concerns such as  
http://en.wikipedia.org/wiki/Cross-site_scripting 
and
http://en.wikipedia.org/wiki/SQL_injection

Anyway, if you used encodeURIComponent() at some point, then later at some point you must use decodeURIComponent().  But, maybe you should be doing all this at the server. Are you sending the request to a Servlet ?
0
 

Author Comment

by:icefinges
ID: 34914943
I am concerned but it is part of a small CMS, therefore only authorized and responsible people should have access to it. Thanks for the advice.
 
In fact I was decoding it at the server-side, with URLDecode, but it was rising lots of problems so you have lead me to the solution. Now I encode and decode at the client-side.
 
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi,    When I first started to learn Hibernate I found it pretty easy, but integrating it with Spring took me around 2 weeks. Not pretty cool. So I came up with the idea of writing this article which guides you simply towards the integration. NO…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question