Author |
Topic |
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 10 November 2005 : 18:39:07
|
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
|
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< |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 11 November 2005 : 04:49:39
|
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 |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 11 November 2005 : 06:37:35
|
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.” |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 11 November 2005 : 07:46:37
|
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 |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 23 November 2005 : 14:21:56
|
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 |
|
|
Nertz
Junior Member
Canada
341 Posts |
Posted - 05 December 2005 : 08:38:04
|
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 |
|
|
Podge
Support Moderator
Ireland
3775 Posts |
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
|
Podge
Support Moderator
Ireland
3775 Posts |
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 09 February 2006 : 10:43:28
|
why would anyone encase a valid url with [url][/url] ?< |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 09 February 2006 : 11:01:58
|
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 |
|
|
masterao
Senior Member
Sweden
1678 Posts |
Posted - 09 February 2006 : 15:03:55
|
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 |
|
|
taropatch
Average Member
USA
741 Posts |
Posted - 09 February 2006 : 15:33:05
|
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.< |
|
|
golfmann
Junior Member
United States
450 Posts |
Posted - 17 February 2006 : 13:11:03
|
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. < |
|
|
|
Topic |
|
|
|