Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 question : filtering + from URLs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 02 May 2006 :  03:30:17  Show Profile  Visit MarcelG's Homepage  Reply with Quote
Just a quick question.
The function ReplaceURLs filters some characters from URLs, like for instance the ",;,+,(,),*,',> and <.
I can imagine why you wouldn't want those characters in an URL, because of XSS attacks etc, but, I'm a bit confused about the + sign.
Is it so dangerous to allow the + to be used in an URL ?

It's giving some headaches when users want to post an URL that uses it.
If they post it as a normal URL, it works:
http://www.somewebsite.com/page.php?name=john+doe&otherparam=somethingelse
when encapsulating that same url in the URL tags, the + is removed, thus breaking the URL.
within the url tags: http://www.somewebsite.com/page.php?name=john doe&otherparam=somethingelse
within the url="" tags: testing.<

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 02 May 2006 03:30:58

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 02 May 2006 :  03:58:11  Show Profile  Visit HuwR's Homepage  Reply with Quote
it is to prevent people posting javascript functions in the url's if it causes you a problem then just remove the check for + from your code<
Go to Top of Page

muzishun
Senior Member

United States
1079 Posts

Posted - 02 May 2006 :  11:01:54  Show Profile  Visit muzishun's Homepage  Reply with Quote
Is it possible to use html entities in javascript? For example, would this:
if (x == y && y == z) {stuff here;}

Work for this:
if (x == y && y == z) {stuff here;}

My guess is that it wouldn't. Since the "&" is an html reference, and the "&" needs to be a literal character in javascript, I would assume that the first function wouldn't work at all. If that's the case, rather than filter symbols out of URLs, you could convert them to their html entity reference. These work just fine when used in URLs, but will probably still prevent the javascript from being included.

Here is a link to an entity reference list at W3Schools.<

Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)

Edited by - muzishun on 02 May 2006 11:03:11
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 02 May 2006 :  11:19:59  Show Profile  Visit AnonJr's Homepage  Reply with Quote
I don't know... I had some problems a while back with URLs that had "&amp;" instead of a literal "&" - some of the querystring values weren't getting passed right. It could have just been a fluke, but I'd do some testing first...<
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 02 May 2006 :  11:23:59  Show Profile  Visit HuwR's Homepage  Reply with Quote
& amp; does not work in a url instead of &<

Edited by - HuwR on 02 May 2006 11:24:52
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 02 May 2006 :  11:43:21  Show Profile  Visit AnonJr's Homepage  Reply with Quote
quote:
Originally posted by HuwR

& amp; does not work in a url instead of &


I thought so. I was just thinking about what muzishun posted...

quote:
Originally posted by muzishun

My guess is that it wouldn't. Since the "&" is an html reference, and the "&" needs to be a literal character in javascript, I would assume that the first function wouldn't work at all. If that's the case, rather than filter symbols out of URLs, you could convert them to their html entity reference. These work just fine when used in URLs, but will probably still prevent the javascript from being included.
<
Go to Top of Page

muzishun
Senior Member

United States
1079 Posts

Posted - 02 May 2006 :  15:42:26  Show Profile  Visit muzishun's Homepage  Reply with Quote
The HTML entities do work in standard html code. If you are using them within the vbScript side of code, you're correct, they don't work properly. But they do in fact work in standard links. For example, this:
Response.write "<a href=""http://search.yahoo.com/search?p=snitz&sm=Yahoo%21+Search&fr=FP-tab-web-t&toggle=1&cop=&ei=UTF-8"">Link</a>

and this:
Response.write "<a href=""http://search.yahoo.com/search?p=snitz& amp;sm=Yahoo%21+Search& amp;fr=FP-tab-web-t& amp;toggle=1& amp;cop=& amp;ei=UTF-8"">Link</a>

do the same thing (minus the spaces, of course).

However, in this case:
Response.redirect("http://search.yahoo.com/search?p=snitz& amp;sm=Yahoo%21+Search& amp;fr=FP-tab-web-t& amp;toggle=1& amp;cop=& amp;ei=UTF-8")

the & amp; entities would not work. You would have to leave them as literal "&" symbols.

This link is a page using the following code:
<html>
<body>
<%
Response.write "The link below uses standard ""&"" symbols.<br /><a href=""http://search.yahoo.com/search?p=snitz&sm=Yahoo%21+Search&fr=FP-tab-web-t&toggle=1&cop=&ei=UTF-8"">Link</a><br /><br />" & vbNewline
Response.write "The link below uses the ""&amp;"" entity reference.<br /><a href=""http://search.yahoo.com/search?p=snitz&sm=Yahoo%21+Search&fr=FP-tab-web-t&toggle=1&cop=&ei=UTF-8"">Link</a><br /><br />" & vbNewline
%>
</body>
</html>
<

Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)

Edited by - muzishun on 02 May 2006 15:50:28
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000 Version 3.4.07