Jump to content

URLEncode problem


nscnick

Recommended Posts

I have an access database which is searched through a frontpage generated asp page SQL query. The problem is that it translates a web address hyperlink with a %2E instead of the period, even though the link is displayed on the page correctly.Does anybody have any ideas how this can be prevented? I cannot see any immediately obvious locations in the html.

Link to comment
Share on other sites

If you're using a PHP file or HTML, this wouldn't happen, because when HTML is used (in either a PHP file or HTM file) the URLs are literal and you don't need stuff like that.

<a href="blah%2Ephp">

Is the same as

<a href="blah.php">

to HTML. HTML uses it interchangeably, and does not convert them to URL-safe things such as that. (Unless sending it through a query like you have done.)

Link to comment
Share on other sites

If you need a way to decode the URLEncode, try this.

dim str str = Server.URLEncode("/open.asp")response.write(str)response.write("<br />")response.write(URLDecode(str))function URLDecode(sText)sDecoded = sTextSet oRegExpr = Server.CreateObject("VBScript.RegExp")oRegExpr.Pattern = "%[0-9,A-F]{2}"oRegExpr.Global = TrueSet oMatchCollection = oRegExpr.Execute(sText)For Each oMatch In oMatchCollectionsDecoded = Replace(sDecoded,oMatch.value,Chr(CInt("&H" & Right(oMatch.Value,2))))NextURLDecode = sDecodedEnd function

Link to comment
Share on other sites

This is the asp fragment that takes the access field (called www) containing the url:s-column="www" b-tableformat="FALSE" b-hasHTML="FALSE" clientside local_preview="<font size="-1">&lt;&lt;</font>www<font size="-1">&gt;&gt;</font>" preview="<font size="-1">&lt;&lt;</font>www<font size="-1">&gt;&gt;</font>" --><%=FP_FieldVal(fp_rs,"www")%><!--webbot bot="DatabaseResultColumn" i-CheckSum="7628" endspan -->The resulting viewable page (in the browser) generates as source code:<td width="547" bgcolor="#FFFFFF" height="18"><!--mstheme--><font face="Arial, Arial, Helvetica"> <p style="margin-top: 0; margin-bottom: 0"><font size="2"> <a href="http://www%2Enscdesign%2Ecom">www.nscdesign.com </a> </font><!--mstheme--></font></td>I can see the %2E but am unsure how I can change these for the period. There doesn't seem to anything like a URL 'unencode', or should I be looking at asp to do this? I suppose I could write a scan and replace the characters but wouldn't know how to insert into the asp page. This seems to be a result of what happens from the database as putting a url directly into html doesn't produce the encoded periods. So somewhere along the upper fragment generates this change.I wouldn't know where to start trying to work out what the asp fragment is doing.

Link to comment
Share on other sites

That doesn't make a lot of sense to me. Both of those variables, local_preview and preview, are in this form:

<font size="-1"><<</font>www<font size="-1">>></font>

I don't see that in the HTML you pasted, so I can't determine how that HTML is a result of that code. Furthermore, this:

s-column="www" b-tableformat="FALSE" b-hasHTML="FALSE" clientside

is not syntactically-correct ASP code, I'm not sure what it is.What I'm trying to say is that from that code you posted, it is not apparent why the periods are being left encoded.

Link to comment
Share on other sites

Apologies for the length of these bits but I'm notr sure what will or not be relevant (the asp is generated by Frontpage which is called as a result of the query and then obviously generates the resultant source code displayed on the browser - I managed to work that bit out for myself, but beyond that?). The asp page (with most of the output table row code deleted for simplicity)<html><head><meta http-equiv="Content-Language" content="en-gb"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>BDetails</title><meta name="Microsoft Theme" content="sgrp 000, default"><meta name="Microsoft Border" content="tlb, default"></head><body bgcolor="#FFFFCC" text="#000000" link="#0000FF" vlink="#800080" alink="#CC6600"><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><!--mstheme--><font face="Arial, Arial, Helvetica"><div align="left" style="width: 825; height: 151"> <div align="center"> <center><!--mstheme--></font><pre style="margin-top: 0; margin-bottom: 0"> <img border="0" src="images/logos/small%20EU_pf_logo.gif" width="203" height="60"><font size="3"> </font><img border="0" src="images/logos/scvo.gif" width="55" height="59"><font size="3"> </font><a href="http://www.berryscotland.com"><img border="0" src="images/logos/berryscot.gif" width="216" height="45"></a><font face="Comic Sans MS" size="3"> </font><img border="0" src="images/logos/DirectGrantsLogo.gif" width="88" height="59"><font size="3"> </font><img border="0" src="images/logos/se_black.gif" width="172" height="60"></pre><!--mstheme--><font face="Arial, Arial, Helvetica"></center> </div> <center> <blockquote> <div align="center"> <!--mstheme--></font><pre style="margin-top: 0; margin-bottom: 0"><b><span style="text-transform: capitalize; font-variant: small-caps"><font face="Times New Roman" color="#0000FF" size="4"><img border="0" src="images/collogo_small.jpg" align="bottom" width="65" height="50"> </font><font color="#0000FF" face="Franklin Gothic Medium" size="6">S<span style="font-variant: small-caps; text-transform: capitalize">trathmore</span> & </font></span><font color="#0000FF" face="Franklin Gothic Medium" size="6">T<span style="font-variant: small-caps">he</span> G<span style="font-variant: small-caps">lens </span>R<span style="font-variant: small-caps">ural</span> P<span style="font-variant: small-caps">artnership</span></font></b> <b><font face="Times New Roman" color="#0000FF" size="4"><span style="text-transform: capitalize; font-variant: small-caps"><img border="0" src="images/collogo_small.jpg" align="bottom" width="66" height="50"></span></font></b></pre><!--mstheme--><font face="Arial, Arial, Helvetica"> </div> <div align="center"> <!--mstheme--></font><pre style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><a href="http://www.perthshire.com"><img border="0" src="images/logos/Perthshireclassicscotland.gif" width="200" height="55"></a></pre><!--mstheme--><font face="Arial, Arial, Helvetica"> </div> </blockquote> </center></div><!--mstheme--></font></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%"><!--mstheme--><font face="Arial, Arial, Helvetica"> <p></p><p align="center"><a href="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/scotland/rss.xml"><b>BBCNews</b></a></p><p style="margin-top: 1; margin-bottom: 3" align="center"><a href="http://www.google.com"><b><font color="#FF0000"><img border="0" src="images/logos/googlelogo.gif" width="89" height="39"></font></b></a></p><p style="margin-top: 1; margin-bottom: 3" align="center"><a href="http://www.bbc.co.uk/weather/5day.shtml?id=3066&links"><b><font face="Arial Narrow" color="#000000">StrathmoreWeather</font></b></a></p><p style="margin-top: 1; margin-bottom: 3" align="center"><a href="http://www.mwis.org.uk/index.php"><b><font face="Arial Narrow" color="#000000">MountainWeather</font></b></a></p><p><a href="images/walking.gif"><img border="0" src="images/walking_small.gif" width="100" height="75"></a></p><p><a href="images/lochmntns.gif"><img border="0" src="images/lochmntns_small.gif" width="100" height="75"></a></p><p><a href="images/trees.gif"><img border="0" src="images/trees_small.gif" width="100" height="75"></a></p><!--mstheme--></font></td><td valign="top" width="24"></td><!--msnavigation--><td valign="top"><!--mstheme--><font face="Arial, Arial, Helvetica"><p style="margin-top: 0; margin-bottom: 0"><a href="directory/busdirectory.htm" name="top">DirectoryIndex</a>    <a href="index.htm">Home</a></p><p style="margin-top: 0; margin-bottom: 0"> </p><!--webbot bot="DatabaseRegionStart" startspans-columnnames="ID,name,nameinit,title,fname,sname,position,address1,address2,address3,town,postcode,daytel,evetel,mob,fax,email,www,object,objectinit,aims,affiliation,membreq,agegps,charges,venue,times,wheelch,notes,remarks"s-columntypes="3,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202"s-dataconnection="business" b-tableformat="FALSE" b-menuformat="FALSE"s-menuchoice="name" s-menuvalue="name" b-tableborder="TRUE" b-tableexpand="TRUE"b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="FALSE"i-ListFormat="0" b-makeform="FALSE" s-recordsource="Table1"s-displaycolumns="name,title,fname,sname,position,address1,address2,address3,town,postcode,daytel,evetel,mob,fax,email,www,object"s-criteria="[name] EQ {name} +" s-orders-sql="SELECT * FROM Table1 WHERE (name = '::name::')" b-procedure="FALSE"clientside SuggestedExt="asp" s-DefaultFields="name="s-NoRecordsFound="No records returned." i-MaxRecords="1" i-GroupSize="0"BOTID="0" u-dblib="_fpclass/fpdblib.inc" u-dbrgn1="_fpclass/fpdbrgn1.inc"u-dbrgn2="_fpclass/fpdbrgn2.inc" tag="BODY"local_preview="<table border=0 width="100%"><tr><td bgcolor="#FFFF00" align="left"><font color="#000000">Database Results regions will not preview unless this page is fetched from a Web server using a web browser. The section of the page from here to the end of the Database Results region will repeat once for each record returned by the query.</font></td></tr></table>"preview="<table border=0 width="100%"><tr><td bgcolor="#FFFF00" align="left"><font color="#000000">This is the start of a Database Results region. The page must be fetched from a web server with a web browser to display correctly; the current web is stored on your local disk or network.</font></td></tr></table>" b-WasTableFormat="FALSE" --><!--#include file="_fpclass/fpdblib.inc"--><%fp_sQry="SELECT * FROM Table1 WHERE (name = '::name::')"fp_sDefault="name="fp_sNoRecords="No records returned."fp_sDataConn="business"fp_iMaxRecords=1fp_iCommandType=1fp_iPageSize=0fp_fTableFormat=Falsefp_fMenuFormat=Falsefp_sMenuChoice="name"fp_sMenuValue="name"fp_iDisplayCols=17fp_fCustomQuery=FalseBOTID=0fp_iRegion=BOTID%><!--#include file="_fpclass/fpdbrgn1.inc"--><!--webbot bot="DatabaseRegionStart" i-CheckSum="57526" endspan --><!--mstheme--></font><table border="0" width="661" height="294"> <tr>.....The other field items have been deleted between the periods to make it shorter! They are are records within an html two column tableText in the LH, and the field results textbox in the RH..... <td width="90" bgcolor="#CCFFFF" height="18"><!--mstheme--><font face="Arial, Arial, Helvetica"> <p style="margin-top: 0; margin-bottom: 0"><font size="2"><b>website:</b></font><!--mstheme--></font></td> <td width="547" bgcolor="#FFFFFF" height="18"><!--mstheme--><font face="Arial, Arial, Helvetica"> <p style="margin-top: 0; margin-bottom: 0"><font size="2"> <a href="http://<%=FP_FieldURL(fp_rs,"www")%>"><!--webbot bot="DatabaseResultColumn" startspan s-columnnames="ID,name,nameinit,title,fname,sname,position,address1,address2,address3,town,postcode,daytel,evetel,mob,fax,email,www,object,objectinit,aims,affiliation,membreq,agegps,charges,venue,times,wheelch,notes,remarks" s-column="www" b-tableformat="FALSE" b-hasHTML="FALSE" clientside local_preview="<font size="-1">&lt;&lt;</font>www<font size="-1">&gt;&gt;</font>" preview="<font size="-1">&lt;&lt;</font>www<font size="-1">&gt;&gt;</font>" --><%=FP_FieldVal(fp_rs,"www")%><!--webbot bot="DatabaseResultColumn" i-CheckSum="7628" endspan --> </a> </font><!--mstheme--></font></td> </tr> ..... .....</table><!--mstheme--><font face="Arial, Arial, Helvetica"><!--webbot bot="DatabaseRegionEnd" startspan b-tableformat="FALSE"b-menuformat="FALSE" u-dbrgn2="_fpclass/fpdbrgn2.inc" i-groupsize="0" clientsidetag="BODY"local_preview="<table border=0 width="100%"><tr><td bgcolor="#FFFF00" align="center"><font color="#000000">End of Database Results region.</font></td></tr></table>"preview="<table border=0 width="100%"><tr><td bgcolor="#FFFF00" align="left"><font color="#000000">This is the end of a Database Results region.</font></td></tr></table>" --><!--#include file="_fpclass/fpdbrgn2.inc"--><!--webbot bot="DatabaseRegionEnd" i-CheckSum="62730" endspan --><p align="left"><a href="directory/busdirectory.htm">DirectoryIndex</a>    <a href="index.htm">Home</a>    <a href="#top">Top</a></p><p align="left"> <!--mstheme--></font><!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><!--mstheme--><font face="Arial, Arial, Helvetica"><!--mstheme--></font></td></tr><!--msnavigation--></table></body></html>The HTML source (obtained through View Source on the Browser, as above with the non-problem field rows removed):<html><head><meta http-equiv="Content-Language" content="en-gb"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>BDetails</title><meta name="Microsoft Theme" content="sgrp 000, default"><meta name="Microsoft Border" content="tlb, default"></head><body bgcolor="#FFFFCC" text="#000000" link="#0000FF" vlink="#800080" alink="#CC6600"><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><!--mstheme--><font face="Arial, Arial, Helvetica"><div align="left" style="width: 825; height: 151"> <div align="center"> <center><!--mstheme--></font><pre style="margin-top: 0; margin-bottom: 0"> <img border="0" src="images/logos/small%20EU_pf_logo.gif" width="203" height="60"><font size="3"> </font><img border="0" src="images/logos/scvo.gif" width="55" height="59"><font size="3"> </font><a href="http://www.berryscotland.com"><img border="0" src="images/logos/berryscot.gif" width="216" height="45"></a><font face="Comic Sans MS" size="3"> </font><img border="0" src="images/logos/DirectGrantsLogo.gif" width="88" height="59"><font size="3"> </font><img border="0" src="images/logos/se_black.gif" width="172" height="60"></pre><!--mstheme--><font face="Arial, Arial, Helvetica"></center> </div> <center> <blockquote> <div align="center"> <!--mstheme--></font><pre style="margin-top: 0; margin-bottom: 0"><b><span style="text-transform: capitalize; font-variant: small-caps"><font face="Times New Roman" color="#0000FF" size="4"><img border="0" src="images/collogo_small.jpg" align="bottom" width="65" height="50"> </font><font color="#0000FF" face="Franklin Gothic Medium" size="6">S<span style="font-variant: small-caps; text-transform: capitalize">trathmore</span> & </font></span><font color="#0000FF" face="Franklin Gothic Medium" size="6">T<span style="font-variant: small-caps">he</span> G<span style="font-variant: small-caps">lens </span>R<span style="font-variant: small-caps">ural</span> P<span style="font-variant: small-caps">artnership</span></font></b> <b><font face="Times New Roman" color="#0000FF" size="4"><span style="text-transform: capitalize; font-variant: small-caps"><img border="0" src="images/collogo_small.jpg" align="bottom" width="66" height="50"></span></font></b></pre><!--mstheme--><font face="Arial, Arial, Helvetica"> </div> <div align="center"> <!--mstheme--></font><pre style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><a href="http://www.perthshire.com"><img border="0" src="images/logos/Perthshireclassicscotland.gif" width="200" height="55"></a></pre><!--mstheme--><font face="Arial, Arial, Helvetica"> </div> </blockquote> </center></div><!--mstheme--></font></td></tr><!--msnavigation--></table><!--msnavigation--><table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%"><!--mstheme--><font face="Arial, Arial, Helvetica"> <p></p><p align="center"><a href="http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/scotland/rss.xml"><b>BBCNews</b></a></p><p style="margin-top: 1; margin-bottom: 3" align="center"><a href="http://www.google.com"><b><font color="#FF0000"><img border="0" src="images/logos/googlelogo.gif" width="89" height="39"></font></b></a></p><p style="margin-top: 1; margin-bottom: 3" align="center"><a href="http://www.bbc.co.uk/weather/5day.shtml?id=3066&links"><b><font face="Arial Narrow" color="#000000">StrathmoreWeather</font></b></a></p><p style="margin-top: 1; margin-bottom: 3" align="center"><a href="http://www.mwis.org.uk/index.php"><b><font face="Arial Narrow" color="#000000">MountainWeather</font></b></a></p><p><a href="images/walking.gif"><img border="0" src="images/walking_small.gif" width="100" height="75"></a></p><p><a href="images/lochmntns.gif"><img border="0" src="images/lochmntns_small.gif" width="100" height="75"></a></p><p><a href="images/trees.gif"><img border="0" src="images/trees_small.gif" width="100" height="75"></a></p><!--mstheme--></font></td><td valign="top" width="24"></td><!--msnavigation--><td valign="top"><!--mstheme--><font face="Arial, Arial, Helvetica"><p style="margin-top: 0; margin-bottom: 0"><a href="directory/busdirectory.htm" name="top">DirectoryIndex</a>    <a href="index.htm">Home</a></p><p style="margin-top: 0; margin-bottom: 0"> </p><!--mstheme--></font><table border="0" width="661" height="294">......Output rows deleted...... <tr> <td width="90" bgcolor="#CCFFFF" height="18"><!--mstheme--><font face="Arial, Arial, Helvetica"> <p style="margin-top: 0; margin-bottom: 0"><font size="2"><b>website:</b></font><!--mstheme--></font></td> <td width="547" bgcolor="#FFFFFF" height="18"><!--mstheme--><font face="Arial, Arial, Helvetica"> <p style="margin-top: 0; margin-bottom: 0"><font size="2"> <a href="http://www%2Enscdesign%2Ecom">www.nscdesign.com </a> </font><!--mstheme--></font></td> </tr>......Output rows deleted...... </table><!--mstheme--><font face="Arial, Arial, Helvetica"><p align="left"><a href="directory/busdirectory.htm">DirectoryIndex</a>    <a href="index.htm">Home</a>    <a href="#top">Top</a></p><p align="left"> <!--mstheme--></font><!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><!--mstheme--><font face="Arial, Arial, Helvetica"><!--mstheme--></font></td></tr><!--msnavigation--></table></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...