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 Bug Reports (Open)
 BUG - URL-handling.
 New Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 10 November 2005 :  18:39:07  Show Profile  Visit MarcelG's Homepage  Reply with Quote
While looking for a way to clip urls we ran into a bug. At first we thought it were our modifactions, but some testing shows that it happens in the default 3.4.05 install, even here at Snitz (proof)

Symptoms:
When using the [url][/url] or [url=""][/url] tags around a valid URL, the URL is parsed twice through the edit_hrefs function.

Example:
[url]http://www.bladiebla1.com[/url]
outputs this HTML code: (used linebreaks to make it more readable)
<a href="http://www.bladiebla1.com" target="_blank">
<a href="http://www.bladiebla1.com" target="_blank">
http://www.bladiebla1.com
</a></a>


Example 2:
[url="http://www.bladiebla2.com"]http://www.bladiebla3.com[/url]
Outputs this HTML code:
<a href="http://www.bladiebla2.com" target="_blank">
<a href="http://www.bladiebla3.com" target="_blank">
http://www.bladiebla3.com
</a></a>


I think this should be fixed in the next version, but unfortunately I do not have pinpointed the exact cause, nor do I have a working workaround/fix available.<

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 10 November 2005 18:40:04

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 10 November 2005 :  19:31:37  Show Profile  Visit HuwR's Homepage
The problem is in the formatstr function, the following piece of code

	if strAllowForumCode = "1" then
		fString = ReplaceURLs(fString)
		fString = ReplaceCodeTags(fString)
		if strIMGInPosts = "1" then
			fString = ReplaceImageTags(fString)
		end if
	end if

	fString = ChkURLs(fString, "http://", 1)
	fString = ChkURLs(fString, "https://", 2)
	fString = ChkURLs(fString, "www.", 3)
	fString = ChkMail(fString)
	fString = ChkURLs(fString, "ftp://", 5)
	fString = ChkURLs(fString, "file:///", 6)

as you can see fstring is passed to ReplaceUrls and then to chkurls, both of these functions pass the string through edit_hrefs<
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 November 2005 :  04:49:39  Show Profile  Visit MarcelG's Homepage
so, this would be the fix:
	if strAllowForumCode = "1" then
		fString = ReplaceURLs(fString)
		fString = ReplaceCodeTags(fString)
		if strIMGInPosts = "1" then
			fString = ReplaceImageTags(fString)
		end if
	end if
	if strAllowForumCode <> "1" then
	fString = ChkURLs(fString, "http://", 1)
	fString = ChkURLs(fString, "https://", 2)
	fString = ChkURLs(fString, "www.", 3)
	fString = ChkMail(fString)
	fString = ChkURLs(fString, "ftp://", 5)
	fString = ChkURLs(fString, "file:///", 6)
	end if
If forumcode is allowed, do the ReplaceURL's function.
If forumcode is not allowed, just do the chkUrls functions?


That was not the correct method.

I modified the ChkURLS function:
function ChkURLs(ByVal strToFormat, ByVal sPrefix, ByVal iType)
	Dim strArray
	Dim Counter

	ChkURLs = strToFormat

	if InStr(1, strToFormat, sPrefix) > 0 Then
		strArray = Split(strToFormat, sPrefix, -1)
		ChkURLs = strArray(0)

		for Counter = 1 To UBound(strArray)
			if ((strArray(Counter-1) = "" Or Len(strArray(Counter-1)) < 5) And strArray(Counter)<> "") then
				ChkURLs = ChkURLs & edit_hrefs(sPrefix & strArray(Counter), iType)
			elseif ((UCase(Right(strArray(Counter-1), 6)) <> "HREF=""") and _
				(UCase(Right(strArray(Counter-1), 5)) <> "[IMG]") and _
				(UCase(Right(strArray(Counter-1), 5)) <> "[URL]") and _
				(UCase(Right(strArray(Counter-1), 6)) <> "[URL=""") and _
				(UCase(Right(strArray(Counter-1), 8)) <> "_BLANK"">") and _
				(UCase(Right(strArray(Counter-1), 6)) <> "ftp://") and _
				(UCase(Right(strArray(Counter-1), 8)) <> "file:///") and _
				(UCase(Right(strArray(Counter-1), 7)) <> "http://") and _
				(UCase(Right(strArray(Counter-1), 8)) <> "https://") and _
				(UCase(Right(strArray(Counter-1), 5)) <> "SRC=""") and _
				(strArray(Counter) <> "")) then

				ChkURLs = ChkURLs & edit_hrefs(sPrefix & strArray(Counter), iType)
			else
				ChkURLs = ChkURLs & sPrefix & strArray(Counter)
			end if
		next
	end if
end function

Added the red bold line, which checks if it's parsing an url that was already parsed (recognizable by the _blank"> part.
It seems to be working.... I'm not sure if that's the correct method.<

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 11 November 2005 12:24:03
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 November 2005 :  06:37:35  Show Profile
Perhaps a check in the chkURLs function to see whether the 4 characters suceeding the URI in fstring are not </a> before calling the edit_hrefs function would do the trick. Or would there be more to it than that?

<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 November 2005 :  07:46:37  Show Profile  Visit MarcelG's Homepage
Update 2:
The function I pasted about is Basecode 3.4.05;
The function below also incorporates the bugfix discussed a while ago, about URL's ending with a dot etc.

function ChkURLs(ByVal strToFormat, ByVal sPrefix, ByVal iType)
	Dim strArray
	Dim Counter
	if InStr(strToFormat, sPrefix)>0 then
	 Dim StrArray1
	 Dim LastChar, i
	 strToFormat = Replace(StrToFormat, "<br />", " :: ")
	  StrArray1 = split(strToFormat, " ")
	    if not(UBound(strArray1)<1) then
		  For i=0 to Ubound(strArray1)
		    if Left(strArray1(i), len(sPrefix))=sPrefix then
			 LastChar = Right(strArray1(i), 1)
			 'response.write(LastChar)
			  Select Case LastChar
			    Case ".",",","!","?",";",":"
				 strArray1(i) = Left(strArray1(i), len(strArray1(i))-1) & "<b></b>" & LastChar
			  End Select
		     end if
		   i=i+1
		  Next
	    else
		    if Left(strArray1(0), len(sPrefix))=sPrefix then
			 LastChar = Right(strArray1(0), 1)
			 'response.write(LastChar)
			  Select Case LastChar
			    Case ".",",","!","?",";",":"
				 strArray1(0) = Left(strArray1(0), len(strArray1(0))-1) & "<b></b>" & LastChar
			  End Select
		    end if
	    end if
	  strToFormat = Join(strArray1, " ")
	  strToFormat = Replace(strToFormat, " :: ", "<br />")
	end if



	ChkURLs = strToFormat

	if InStr(1, strToFormat, sPrefix) > 0 Then
		strArray = Split(strToFormat, sPrefix, -1)
		ChkURLs = strArray(0)

		for Counter = 1 To UBound(strArray)
			if ((strArray(Counter-1) = "" Or Len(strArray(Counter-1)) < 5) And strArray(Counter)<> "") then
				ChkURLs = ChkURLs & edit_hrefs(sPrefix & strArray(Counter), iType)
			elseif ((UCase(Right(strArray(Counter-1), 6)) <> "HREF=""") and _
				(UCase(Right(strArray(Counter-1), 5)) <> "[IMG]") and _
				(UCase(Right(strArray(Counter-1), 5)) <> "[URL]") and _
				(UCase(Right(strArray(Counter-1), 6)) <> "[URL=""") and _
				(UCase(Right(strArray(Counter-1), 8)) <> "_BLANK"">") and _
				(UCase(Right(strArray(Counter-1), 6)) <> "ftp://") and _
				(UCase(Right(strArray(Counter-1), 8)) <> "file:///") and _
				(UCase(Right(strArray(Counter-1), 7)) <> "http://") and _
				(UCase(Right(strArray(Counter-1), 8)) <> "https://") and _
				(UCase(Right(strArray(Counter-1), 5)) <> "SRC=""") and _
				(UCase(Right(strArray(Counter-1), 1)) <> "-") and _
				(UCase(Right(strArray(Counter-1), 1)) <> "=") and _
				(strArray(Counter) <> "")) then

				ChkURLs = ChkURLs & edit_hrefs(sPrefix & strArray(Counter), iType)
			else
				ChkURLs = ChkURLs & sPrefix & strArray(Counter)
			end if
		next
	end if
end function
I know we had some discussion back then about whether or not that first part was covering a real bug or not, but still I'd like to include that one here in the fix.<

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 11 November 2005 12:24:03
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 23 November 2005 :  14:21:56  Show Profile  Visit MarcelG's Homepage
Just checking ; is my proposed solution accepted as fix for this bug, and noted to be in 3.4.06 ?
If so, I can finalize the clipping-urls mod, which requires this bug to be fixed prior to implementation.<

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

Nertz
Junior Member

Canada
341 Posts

Posted - 05 December 2005 :  08:38:04  Show Profile
Just wondering what is the status of this issue and if an official fix is being released. I've encountered the same problem with my WYSIWYG post editor mod, and I can't seem to get around it. Marcel's proposed solution may work in forum code, but still has problems if HTML is allowed and a URL is posted without the "http://" prefix and/or without "target=_blank" string.

cheers,
Nat<

Sadly, most Family Court Judges wrongfully reward opportunistic gold diggers
that use our children unjustly as "instruments" of power.


www.fathers-4-justice-canada.ca
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 08 February 2006 :  18:07:17  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Related Bumpage.

A user of mine recently drew this to my attention. He was trying to post a link using a proxy service e.g. http://webwarper.net/ww/~GZ/http://www.yahoo.com

The link above gets split in two although its supposed to be just one. I know that its because of the two instances of http://
Would checking for a space before http:// https:// etc. fix it?<

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 09 February 2006 :  03:45:20  Show Profile  Visit MarcelG's Homepage
Podge ; I don't think it would, cause that would mean that any new line starting with an url isn't handled.
For instance this one:
http://bla.com<

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 09 February 2006 :  08:50:01  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
I didn't think it checked by line. Don't you pass a string and prefix to the chkurls function?
e.g. fString = ChkURLs(fString, "http://", 1)
and it will check for all instances of http:// and return a string with href's inserted as appropriate.

The beginning of the string could be checked to see if it started with http://<

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 09 February 2006 :  10:43:28  Show Profile
why would anyone encase a valid url with [url][/url] ?<
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 09 February 2006 :  11:01:58  Show Profile  Visit MarcelG's Homepage
quote:
Originally posted by RichardKinser

why would anyone encase a valid url with [url][/url] ?

Good question, but some people do use it.
Nevertheless, even if it shouldn't be used for valid urls, it shouldn't handle the valid URL twice.

Here's an example of a fully valid url that cannot be shown using Snitz as a real URL:
http://www.blabla.com/forward.to?www.blabla.com
This one suffers from almost the same issue.
First, the entire URL is handled as an URL, and transferred to this:

<a href="http://www.blabla.com/forward.to?www.blabla.com" target="_blank">http://www.blabla.com/forward.to?www.blabla.com</a>
Right after that, the green section is also converted to an URL.
<a href="http://www.blabla.com/forward.to?www.blabla.com" target="_blank">http://www.blabla.com/forward.to?<a href="http://www.blabla.com" target="_blank">http://www.blabla.com</a></a>
<

portfolio - linkshrinker - oxle - twitter
Go to Top of Page

masterao
Senior Member

Sweden
1678 Posts

Posted - 09 February 2006 :  15:03:55  Show Profile  Visit masterao's Homepage
quote:
Originally posted by RichardKinser

why would anyone encase a valid url with [url][/url] ?



to add a . or ; or , after the url without breaking it. Also when enclosing the url with () or even [].<

Jan
===========
FR Portal Forums | Active Users 4.0.20 Mod
Go to Top of Page

taropatch
Average Member

USA
741 Posts

Posted - 09 February 2006 :  15:33:05  Show Profile
quote:
Originally posted by RichardKinser

why would anyone encase a valid url with [url][/url] ?

Sometimes, I do it at my forum if the url is at the end of a sentence. Otherwise the period is included and people get a dead link.

http://www.period.com.
http://www.noperiod.com.<
Go to Top of Page

golfmann
Junior Member

United States
450 Posts

Posted - 17 February 2006 :  13:11:03  Show Profile  Visit golfmann's Homepage
hmmmmm
So there are about 3 issues so far?
The vBulletin Concatenated URL's seem best as Marcel showed on anoher thread.

quote:
Originally posted by MarcelG

I did that just now, and now there simply is no URL handling left. All the text is left intact, and www.1234567890.com is shown as www.1234567890.com

BTW ; vBulletin has the clipping function!
www.vbulletin.com/forum/showthread.php?p=1008045#post1008045" target="_blank">proof



BTW my button hack thing allows double http's without splitting, so that's a clue for someone smarter than I. <
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000 Version 3.4.07