Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 01-18-2006, 10:10 AM Store HTML in cookie
Super Talker

Posts: 148
Trades: 0
I tried storing html information such as:
Code:
<p>Test123</p>
Tried saving the code above in a cookie using javascript but cant seem to work. I had this error:
A potentially dangerous Request.Cookies value was detected from the client (desc="<STRONG>Test </STRON...").

Is there any other way i can store such html information and use it in another web page? Thanks
shaoen01 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-18-2006, 10:19 AM
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
Why not just store "Test123" and then add the HTML wherever you're outputting the data? If you want to change the formatting later on, you can't because the user's cookie is formatted differently.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 01-18-2006, 10:29 AM
Super Talker

Posts: 148
Trades: 0
If user adds in tags like "<p>", how do i escape such characters? I have this editor tool that allows them to do formatting such as bold, underline, etc. And i would like it to remember the value if they go to another page and come back again. Both the html tags and value "Test123" is important to me.
shaoen01 is offline
Reply With Quote
View Public Profile
 
Old 01-18-2006, 10:46 PM
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
You can URLencode the data, then decode it... see here for a demo:
http://www.albionresearch.com/misc/urlencode.php
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 01-19-2006, 06:13 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
The error you're seeing is caused by the .NET Framework. Thats one of the good things about .NET - it warns you of some types of potentially malicios user input by default. In this case, it is telling you that someone is trying to post HTML code to your page.

The reason this is not allowed is because a user could inject some HTML in there (for example, a bit of javascript redirecting to their own site) and then if you write this data back to clients at any point, the javascript will be executed and users will be redirected to another site (or shown popups, or whatever the malicious user inserted)

If you know that there's no feasible way for this to happen, you can turn off this validation very easily, although it's not reccomended.
<@ Page language="VB" ValidateRequest="false" %>
Or (definitly not reccomended) yo ucan turn it off for the entire site in web.config by adding
<pages ValidateRequest="false" />
into your web.config file.

Instead, what you should do is use something like BBCode and only allow the tags you want, such as [p], [b], [i], etc. that when converted to HTML can't really do any damage at all.
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Reply     « Reply to Store HTML in cookie
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44055 seconds with 12 queries