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 MOD-Group
 MOD Add-On Forum (W/O Code)
 Clipped URL's?
 New Topic  Reply to Topic
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 6

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 November 2005 :  08:09:32  Show Profile  Reply with Quote
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.”
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 November 2005 :  09:12:04  Show Profile  Visit MarcelG's Homepage  Reply with Quote
quote:
Originally posted by Podge

What was the suggested fix?

Mine was this one:
http://www.oxle.com/topic.asp?TOPIC_ID=3292#31149 (it's dutch, but I think you know what I mean).
E.g., checking for _blank"> prior to parsing it though the function.<

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

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 November 2005 :  09:12:16  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
Can't we try that anyways? =)
<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 November 2005 :  09:15:33  Show Profile  Reply with Quote
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.”
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 November 2005 :  10:14:53  Show Profile  Visit MarcelG's Homepage  Reply with Quote
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
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 November 2005 :  10:17:03  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
Ok, ok.. I'm in no hurry =)
<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

RArch
Junior Member

United Kingdom
103 Posts

Posted - 06 December 2005 :  17:14:49  Show Profile  Reply with Quote
Any update on this?

Some of my users just love to post long ebay links in my forum...

<
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 07 December 2005 :  02:53:32  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
We're waiting for answers in this thread http://forum.snitz.com/forum/topic.asp?TOPIC_ID=60140
<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 02 February 2006 :  08:52:07  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
Any news? =)<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 03 April 2006 :  09:06:09  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message  Reply with Quote
bumpetibump...
<

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 20 April 2006 :  09:59:53  Show Profile  Visit MarcelG's Homepage  Reply with Quote
I've wrapped up the changes I made as a 'mod' : See here for instructions.<

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

RArch
Junior Member

United Kingdom
103 Posts

Posted - 20 April 2006 :  15:33:27  Show Profile  Reply with Quote
Thanks for that MarcelG works a treat with SHN beta v9 too.
<
Go to Top of Page

Eric Coleman
Starting Member

USA
10 Posts

Posted - 29 July 2006 :  14:43:36  Show Profile  Reply with Quote
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.<
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 30 July 2006 :  06:15:19  Show Profile  Visit MarcelG's Homepage  Reply with Quote
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
Go to Top of Page

Eric Coleman
Starting Member

USA
10 Posts

Posted - 30 July 2006 :  11:02:55  Show Profile  Reply with Quote
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
<
Go to Top of Page
Page: of 6 Previous Topic Topic Next Topic  
Previous Page | Next Page
 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.1 seconds. Powered By: Snitz Forums 2000 Version 3.4.07