Print Page | Close Window

converting text in DB

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=6123
Printed Date: 13 April 2026 at 8:49am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: converting text in DB
Posted By: Mattblack
Subject: converting text in DB
Date Posted: 02 October 2003 at 3:11pm

Hi all,

Just wondering how to solve this...

Im using V6.4 on my website.  When people register or post, it all appears as normal, but if you look in the database then you get things like this inserted all over the place....
o

So when i create a page to draw certain strings and email address out of the database, i have things like that all over the page and need to get rid of it.  I know its got to be something to do with the language file or something, but what is it?  And what should i include on the pages that i create to stop it from happening???

Cheers

Matt




Replies:
Posted By: Gullanian
Date Posted: 02 October 2003 at 3:20pm

thgins like &#111; are HTML entities which stand for potentialy hamrful symbals such as ', <, >, % etc etc.  By replacing them with their HTML entity equivalent you make inputting data more secure.

Its a sacrafice worth making.



Posted By: WebWiz-Bruce
Date Posted: 02 October 2003 at 3:26pm
The forum code has a function to decode this.

You need to run the data you pull from the database through the following function:-

'*********************************************
'***         Decode HTML encoding         *****
'*********************************************

'Decode encoded strings
Private Function decodeString(ByVal strInputEntry)

    'DEcode HTML character entities

    strInputEntry = Replace(strInputEntry, "&#097;", "a", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#098;", "b", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#099;", "c", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#100;", "d", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#101;", "e", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#102;", "f", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#103;", "g", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#104;", "h", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#105;", "i", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#106;", "j", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#107;", "k", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#108;", "l", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#109;", "m", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#110;", "n", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#111;", "o", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#112;", "p", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#113;", "q", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#114;", "r", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#115;", "s", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#116;", "t", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#117;", "u", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#118;", "v", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#119;", "w", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#120;", "x", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#121;", "y", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#122;", "z", 1, -1, 0)

    strInputEntry = Replace(strInputEntry, "&#065;", "A", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#066;", "B", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#067;", "C", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#068;", "D", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#069;", "E", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#070;", "F", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#071;", "G", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#072;", "H", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#073;", "I", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#074;", "J", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#075;", "K", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#076;", "L", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#077;", "M", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#078;", "N", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#079;", "O", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#080;", "P", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#081;", "Q", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#082;", "R", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#083;", "S", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#084;", "T", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#085;", "U", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#086;", "V", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#087;", "W", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#088;", "X", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#089;", "Y", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#090;", "Z", 1, -1, 0)
   
    strInputEntry = Replace(strInputEntry, "&#061;", "=", 1, -1, 0)


    strInputEntry = Replace(strInputEntry, "&#048;", "0", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#049;", "1", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#050;", "2", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#051;", "3", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#052;", "4", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#053;", "5", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#054;", "6", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#055;", "7", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#056;", "8", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&#057;", "9", 1, -1, 0)
   
    strInputEntry = Replace(strInputEntry, "&lt;", "<", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&gt;", ">", 1, -1, 0)
    strInputEntry = Replace(strInputEntry, "&amp;", "&", 1, -1, 0)

    'Return
    decodeString = strInputEntry
End Function



-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: Mattblack
Date Posted: 03 October 2003 at 10:22am

ok, im good - but not THAT good.  Thanks so far though

How do i include that in my asp then?

For example, a simple bit of code might read email addresses from it, that will obviously contain harmful characters.

It would read like this....

<% Dim rs
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open "members", "DSN=mydnshere"
While Not rs.EOF
Response.Write "" & rs("email")
Response.Write "<br>"
rs.MoveNext
Wend
rs.Close
Set rs = Nothing %>

How would i include it in the example shown?

Cheers again!



Posted By: WebWiz-Bruce
Date Posted: 03 October 2003 at 10:40am
If you are showing it on a web page you dn't need to remove the encoding as they are HTML character entities so your browser will display them as the correct characters to anyone viewing the web page.

If you really must remove them then use this code:-

<% Dim rs
Set rs = Server.CreateObject ("ADODB.Recordset")
rs.Open "members", "DSN=mydnshere"
While Not rs.EOF
Response.Write "" &
decodeString(rs("email"))
Response.Write "<br>"
rs.MoveNext
Wend
rs.Close
Set rs = Nothing %>

Put the bit in shown in red and also include the function from my last post somewhere in the same asp file.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: Mattblack
Date Posted: 04 October 2003 at 5:22am

GOT IT!

Thanks guys! 

~Matt ( http://www.zeuscomputers.co.uk - www.zeuscomputers.co.uk )



Posted By: Detonator
Date Posted: 23 June 2005 at 6:27am
Originally posted by Gullanian Gullanian wrote:

thgins like &#111; are HTML entities which stand for potentialy hamrful symbals such as ', <, >, % etc etc.  By replacing them with their HTML entity equivalent you make inputting data more secure.

Its a sacrafice worth making.

 
Hello all,
 
I came along to this page looking for information on a script that I'm working on for WW, and I was having this same problem regarding these "special" characters getting replaced by "&#nnn" entities. I understand the problem with things like <, >, %, etc. But, out of curioisity, what harm can the letter "o" (ASCII code 111) do? because this letter specifically gets replaced by &#111 and I can't see any logic reason to do this, as it's plain a plain letter.
 
Thanks


Posted By: dpyers
Date Posted: 23 June 2005 at 12:36pm
I believe Borg has included the alphabet in the decode function because he also encodes some reserved words that could be entered in text boxes and used as part of an sql injection attack.

-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net