Reply
ASP Decode
Old 09-29-2006, 06:01 PM ASP Decode
Novice Talker

Posts: 12
Hi.

I have a webpage that pulls some HTML from an access database. The tags (such as <, >, &...ect) are encoded to &lt;, &gt; ect..., and I need them decoded back so they display properly. I havn't the slightest idea how to do this. Any help?

Thanks.
MIDNIGHTBANDIT9 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 09-29-2006, 07:07 PM Re: ASP Decode
chrishirst's Avatar
Super Moderator

Posts: 12,845
Location: Blackpool. UK
Code:
replace(strData, "&gt;",">")
replace(strData, "&lt;","<")
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-29-2006, 08:55 PM Re: ASP Decode
Novice Talker

Posts: 12
I get:

Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub

How can I fix that?

Thanks.
MIDNIGHTBANDIT9 is offline
Reply With Quote
View Public Profile
 
Old 09-30-2006, 05:07 AM Re: ASP Decode
chrishirst's Avatar
Super Moderator

Posts: 12,845
Location: Blackpool. UK
Set the replace up fully and correctly in the code that displays your data.
I only showed examples of how to use the replace function

If you only have two HTML entities to replace ( &gt; & &lt; ) then use nested replace functions.
Code:
 
response.write replace(replace(strData, "&gt;",">"), "&lt;","<")
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-30-2006, 10:09 AM Re: ASP Decode
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
The question I have is...why would you want to?

The whole point of HTML encoding tags is to ensure that those who have malicious intentions (e.g. malicious scripting) won't be able to pull those off.

And if they're stored in the database that way, then you've probably at some point had to encode them using Server.HTMLEncode. The easier thing to do is simply to remove that at the point which it's being called. Mind you, you're opening yourself up to some huge security stuff.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 10-01-2006, 08:01 AM Re: ASP Decode
chrishirst's Avatar
Super Moderator

Posts: 12,845
Location: Blackpool. UK
Don't see it a case of using HTML.Encode.

The page data is stored in the table with the tags stored as &lt:body&gt; (for example) so they will display as that, rather than be seen as HTML code and be parsed correctly by browsers.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System

Last edited by chrishirst : 10-01-2006 at 08:02 AM.
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-17-2006, 04:08 AM Re: ASP Decode
Novice Talker

Posts: 6
Private Function HTMLDecode(byVal encodedstring)
Dim tmp, i
tmp = encodedstring
tmp = Replace( tmp, "&quot;", chr(34) )
tmp = Replace( tmp, "&lt;" , chr(60) )
tmp = Replace( tmp, "&gt;" , chr(62) )
tmp = Replace( tmp, "&amp;" , chr(38) )
tmp = Replace( tmp, "&nbsp;", chr(32) )
For i = 1 to 255
tmp = Replace( tmp, "&#" & i & ";", chr( i ) )
Next
HTMLDecode = tmp
End Function
dumack is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ASP Decode
 

Thread Tools

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

vB 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.13699 seconds with 13 queries