Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CRM 2011 Opportunity Bug 18 145
Use Highcharts to plot real time data 5 135
Javascript Urgent help (Need help to disable event handler) 8 41
jsp error 6 25
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…
WHY MVC is the future technology... As many of you know, MVC is Model,View,Controller pattern. Model View Controller pattern was invented in a Smalltalk context at Xerox in late 1970s. Why is this buzz about MVC: --------------------------- …
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…

839 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