Solved

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

Posted on 2011-02-16
2
727 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How To Remove a Principal from HttpServletRequest 4 46
using placeholders where value is empty 3 26
struts exact match support 3 56
login jsp example 24 50
Hi,      I've been learning Spring and Jersey for the past few months and to say in simple, i am pretty much impressed with these frameworks. Many developers feel it awkward to implement a RESTful Web Services with such a popular Web Application Fr…
There is a huge demand for CodeIgniter among the PHP web developers due to its dynamic features and benefits these days. It is one of most popular and agile open source PHP framework for creating robust web applications in PHP web development field.…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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