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)
 inc_func_common.asp - URL Parsing
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 20 February 2003 :  02:22:27  Show Profile
problem is discussed in this topic: using - on a url

here is the fix:

in the edit_hrefs function (at the bottom of inc_func_common.asp) find this section:

	} else if (iType == 3) {
		sOutput = sOutput.replace(/\b(www\.[\w+\.\:\/\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
			"<a href=\"http://$1\" target=\"_blank\">$1<\/a>");
and replace it with this:
	} else if (iType == 3) {
		sOutput = sOutput.replace(/\b(www\-\.[\w+\.\:\/\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
			"<a href=\"http://$1\" target=\"_blank\">$1<\/a>");

Deleted
deleted

4116 Posts

Posted - 20 February 2003 :  02:50:36  Show Profile
Fixed in v4b04 alpha 03

Stop the WAR!
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 20 February 2003 :  08:27:30  Show Profile
Richard, could you explain the change you made? Does the change you made look for the - before the www?

Support Snitz Forums
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 20 February 2003 :  08:47:50  Show Profile
quote:
Originally posted by Davio

Richard, could you explain the change you made? Does the change you made look for the - before the www?

it looks for it before the first period, it can be before or after the www
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 21 February 2003 :  21:28:52  Show Profile
did you make that change here Richard? Seems to have effected urls typed starting with just www:

www.yahoo.com

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 21 February 2003 :  22:24:53  Show Profile
yes, I did make the change here. Seems the only thing this change did is to block the code that parses URLs that start with just www (no http:// etc...)

so, I am going to recommend that the above change NOT be made, and anyone who has already changed it, to change it back to the original state.

Everytime we start messing around with the code that parses URLs, something gets broken. Sometimes I think we should just make it mandatory to place tags around all URLs.

For the specific situation posted in this topic: using - on a url
the following change should rectify it:

on line #73 of inc_func_common.asp find the following:

				(UCase(Right(strArray(Counter-1), 5)) <> "SRC=""") and _
and insert the following lines of code just below it (on line #74)
				(UCase(Right(strArray(Counter-1), 1)) <> "-") and _
				(UCase(Right(strArray(Counter-1), 1)) <> "=") and _
the second line (testing for an equals sign) will allow urls such as this:

http://www.yoursite.com/refer.asp?refer=www.yahoo.com
Go to Top of Page

Deleted
deleted

4116 Posts

Posted - 22 February 2003 :  01:48:08  Show Profile
The possibilities make it virtually impossible to be covered by a single regexp. Without re-writing the complete logic we will not be able to expand it.

Your suggested change searched for "www-." at the start to recognize it as a url, instead of "www."... This is type 3 detection, so the string does not have a protocol header.

A more general one could be:

sOutput = sOutput.replace(/\b([a-zA-Z0-9\-^.]*www[a-zA-Z0-9\-^.]*\.[\w+\.\:\/\@\_\?\=\&\-\'\#\%\~\;\,\$\!\+\*]+)/gi,
"<a href=\"http://$1\" target=\"_blank\">$1<\/a>");


and changing the

	fString = ChkURLs(fString, "www.", 3)

to

	fString = ChkURLs(fString, "www", 3)


It fully detects (tested):
www.mysite.com
www1.mysite.com
www-1.mysite.com

But not:
e-www.mysite.com => detected as e-www.mysite.com
e-www-1.mysite.com => detected as e-www-1.mysite.com [edit]moved this here[/edit]

It does not test "e-www" because the code in ChkURLs uses the split function to handle it. The "e-" part is left in the previous array element. It can only be detected by changing the split logic IMHO. Therefore the red part marked above is no use as of now.

Stop the WAR!

Edited by - Deleted on 22 February 2003 02:24:38
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 22 February 2003 :  12:18:51  Show Profile
Try this to check if the URL is a valid Format


Example URL's
1. vURL = http://www.mysite.com
2. vURL = http://1-www.mysite.com
3. vURL = http://1-www-1.mysite.com
4. vURL = http://e-www.mysite.com
6. vURL = http://e-www-e.mysite.com
7. vURL = http://1-www-e.mysite.com
8. vURL = http://e-www-1.mysite.com
9. vURL = http://forum.mysite.com

if IsValidURL(vURL) then
 strLink = "<A HREF=""" & vURL & """>" & vURL & </A>"
else
 strLink = vURL
end if

function IsValidURL(ByVal vURL)
 Set objRegEx = New RegExp
 objRegEx.Global = True
 objRegEx.IgnoreCase = True
 objRegEx.Pattern = "^(((http://)|(https://))(([a-zA-Z0-9]{1}\-www)|(www\-[a-zA-Z0-9]{1})|([a-zA-Z0-9]{1}\-www\-[a-zA-Z0-9]{1})|(www)|([a-zA-Z0-9]{1,}))\.([\w\-]{2,})\.([a-zA-Z]{2,})([\w\d\\\/\?\s\=\.\#\&]*))$"
 IsValidURL = objRegEx.Test(vURL)
end function



Edited by - GauravBhabu on 22 February 2003 17:13:43
Go to Top of Page

Grandmaster
Starting Member

Brazil
46 Posts

Posted - 24 February 2003 :  10:23:46  Show Profile  Visit Grandmaster's Homepage  Send Grandmaster an ICQ Message
I got a little confused now. :)

What change(s) should I do to my file(s)?

--
Renato "Grandmaster"
CobiT Foundation 4.1 Certified ID: 90391725
http://www.renato.henriques.nom.br
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 24 February 2003 :  11:52:34  Show Profile
Are you having a problem with urls in your forum? If not, you don't need to make any change.

This bug is still being worked on, as far as I can see. Would need to remove the "FIX" from the title if we haven't found one that will work.

Support Snitz Forums
Go to Top of Page

Deleted
deleted

4116 Posts

Posted - 24 February 2003 :  18:04:06  Show Profile
Davio, that would be fine. Perhaps moving this into dev-discussions is a better solution...

Stop the WAR!
Go to Top of Page

throwithere
Starting Member

10 Posts

Posted - 28 February 2003 :  03:50:50  Show Profile
where exactly does the code for parsing urls with
tags are? the javascript function edit_hrefs() doesn't seem to be working and i haven't changed anything yet. i have traced that messages with
tags go to edit_hrefs() but it doesn't seem to do anything to the message.

please help.
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 13 March 2003 :  00:16:47  Show Profile
What's the final census on this? Should we go with Richard's or GB's solution? GB's solution uses regular expression, which I believe you need to have the latest version of the scripting engine.

Support Snitz Forums
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 13 March 2003 :  06:57:13  Show Profile
I thought the original used regular expressions anyway

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 13 March 2003 :  07:00:17  Show Profile
it uses javascript regular expressions, vbscript regular expressions didn't become available until vbScript v5

http://www.brettb.com/VBScriptRegularExpressions.asp
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 13 March 2003 :  07:01:50  Show Profile
ah, ok.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.23 seconds. Powered By: Snitz Forums 2000 Version 3.4.07