Author |
Topic |
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 11 November 2005 : 08:09:32
|
Looks like it hasn't been moderated yet. I threw in a suggestion as well to check that the 4 characters succeeding the URI in ChkURLs are not </a> before calling the edit_hrefs function.
< |
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 |
|
tribaliztic
Senior Member
Sweden
1532 Posts |
Posted - 11 November 2005 : 09:12:16
|
Can't we try that anyways? =) < |
/Tribaliztic - www.gotlandrace.se -
|
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 11 November 2005 : 09:15:33
|
Great minds, 'ey, Marcel?!
< |
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 : 10:14:53
|
lol, well, with me coming in from the left, and you attacking from the right, we scared the hell out of this bug!
Fredrik, if you want to you can adapt that method, however, for the sake of controlled mod development I think it is wise to still consider it a béta. I'm not sure if my piece of code does what it should do. One of the drawbacks of that method is that you can create phising links with Snitz, so perhaps we need to add something on top of it to prevent that. With a phising URL I mean a URL that looks like the one, but points to another. In HTML looking like this:
<a href="http://unsafetargeturl" target="_blank">http://www.safetarget.com</a> But, perhaps I'm taking this 'issue' too far, because with any forumpackage you can create these phising urls with a method like this one: http://www.safetarget.com Simply add some useless forumcode in the http:// and www part; invisible to the viewer, but visible to the function that stops skips the url from parsing. < |
portfolio - linkshrinker - oxle - twitter |
|
|
tribaliztic
Senior Member
Sweden
1532 Posts |
Posted - 11 November 2005 : 10:17:03
|
Ok, ok.. I'm in no hurry =) < |
/Tribaliztic - www.gotlandrace.se -
|
|
|
RArch
Junior Member
United Kingdom
103 Posts |
Posted - 06 December 2005 : 17:14:49
|
Any update on this?
Some of my users just love to post long ebay links in my forum...
< |
|
|
tribaliztic
Senior Member
Sweden
1532 Posts |
|
tribaliztic
Senior Member
Sweden
1532 Posts |
Posted - 02 February 2006 : 08:52:07
|
Any news? =)< |
/Tribaliztic - www.gotlandrace.se -
|
|
|
tribaliztic
Senior Member
Sweden
1532 Posts |
Posted - 03 April 2006 : 09:06:09
|
bumpetibump... < |
/Tribaliztic - www.gotlandrace.se -
|
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
|
RArch
Junior Member
United Kingdom
103 Posts |
Posted - 20 April 2006 : 15:33:27
|
Thanks for that MarcelG works a treat with SHN beta v9 too. < |
|
|
Eric Coleman
Starting Member
USA
10 Posts |
Posted - 29 July 2006 : 14:43:36
|
In the file inc_func_common.asp, find the function FormatStr,
paste the following code immediately ABOVE the bottom 3 lines of the function, the bottom 3 lines I'm talking about are
FormatStr = fString on Error goto 0 end function
Here is the code to paste,
Dim c, n, m, j, k, i, fString2
c = 60 'max text length to display for a URL
n = 0
m = 0
i = 0
Do
i = m + 1
n = InStr(n + 1, fstring, "<a", 1)
If n = 0 Then Exit Do
m = InStr(n + 1, fstring, "</a", 1)
If m = 0 Then Exit Do
j = InStrRev(fstring, ">", m, 1)
If j > n Then
j = j + 1
k = Mid(fstring, j, m - j)
If Len(k) > c Then
fstring2 = fstring2 & Mid(fstring, i, j - i) & Left(k, c - 3) & "..."
m = m - 1
Else
fstring2 = fstring2 & Mid(fstring, i, m - i)
m = m - 1
End If
Else
fstring2 = fstring2 & Mid(fstring, i, m - i)
m = m - 1
End If
Loop
If i > 0 Then
fstring2 = fstring2 & Mid(fstring, i, Len(fstring) - i + 1)
End If
fString = fString2
How does this work?
The forum doesn't convert the URL bb tags to html untill it's displayed for the user, generally through topic.asp. This section of code parses the HTML after the forum converts the "URL" tags to "A" tags.
If you want to test this code before going live with it, simply surround the code with an
If mlev = 4 Then
End If
block, so that only administrators can see the results. I've tested this with lots of broken HTML to find bugs, but please test it for yourself.< |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 30 July 2006 : 06:15:19
|
Eric,
You're doing this for all instances of <a and </a ? What about urls like these ? <a href="http://www.whatversite.com/image.jpg"><img src="http://www.whatversite.com/thumb.jpg"></a> ? You don't want to shorten those....< |
portfolio - linkshrinker - oxle - twitter |
|
|
Eric Coleman
Starting Member
USA
10 Posts |
Posted - 30 July 2006 : 11:02:55
|
You're right. I forgot to check for stuff like that since I generally don't allow images to be posted on my forum. here is an updated version. There is currently only 1 bug that I'm aware of. The addition of the "..." doesn't cross html boundaries. For example, if clipping to 10 characters, the following would happen, "123456789<i>0</i>abcd" gets converted to "1234567...<i></i>" instead of "1234567..<i>.</i>" This really isn't that important since text is being stripped away and the original formatting, if any, will be messed up.
As before, In the file inc_func_common.asp, find the function FormatStr,
paste the following code immediately ABOVE the bottom 3 lines of the function, the bottom 3 lines I'm talking about are
FormatStr = fString on Error goto 0 end function
Dim c
c = 60 'max text length to display for a URL
Dim n, m, j, k, i, x, y, z, w, v
Dim oReg, oMatches, oMatch
Set oReg = New regExp
n = 0
m = 0
i = 0
'fstring2 = fstring
c = c - 3
if c < 0 then c = 3
Do
i = m + 1
n = InStr(n + 1, fstring, "<a", 1)
If n = 0 Then Exit Do
m = InStr(n + 1, fstring, "</a", 1)
If m = 0 Then Exit Do
'j = InStrRev(fstring, ">", m, 1)
j = InStr(n + 1, fstring, ">", 1)
If j > n And j < m Then
j = j + 1
k = Mid(fstring, j, m - j)
If Len(k) > c Then
'k is a string that needs to be replaced.
oReg.Pattern = "<[^>]*>"
oReg.Global = True
oReg.MultiLine = True
Set oMatches = oReg.Execute(k)
x = 1
w = 0
z = ""
y = ""
v = False
For Each oMatch In oMatches
y = Mid(k, x, (oMatch.FirstIndex + 1) - x)
x = oMatch.FirstIndex + 1 + oMatch.Length
w = w + Len(y)
If v = False Then
If w <= c Then
z = z & y & oMatch.Value
Else 'w > c
y = Left(y, c - (w - Len(y))) & "..."
z = z & y & oMatch.Value
v = True
End If
Else
z = z & oMatch.Value
End If
Next
If v = False Then
y = Mid(k, x, Len(k) + 1 - x)
w = w + Len(y)
If w > c Then
y = Left(y, c - (w - Len(y))) & "..."
End If
z = z & y
End If
'fstring2 = fstring2 & Mid(fstring, i, j - i) & Left(k, c - 3) & "..."
fstring2 = fstring2 & Mid(fstring, i, j - i) & z
m = m - 1
Else
fstring2 = fstring2 & Mid(fstring, i, m - i)
m = m - 1
End If
Else
fstring2 = fstring2 & Mid(fstring, i, m - i)
m = m - 1
End If
'<a </a
Loop
If i > 0 Then
fstring2 = fstring2 & Mid(fstring, i, Len(fstring) - i + 1)
End If
fstring = fstring2
< |
|
|
Topic |
|
|
|