[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Hyperlink_URL2 Trouble
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Hyperlink_URL2 Trouble

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Bbfreak   (9 posts)  [Biography] bio
Date Thu 01 Oct 2009 07:16 PM (UTC)
Message
Most of the time the plugin works fine, but every now and then it crashes. Giving me the following error below.

Run-time error
Plugin: Hyperlink_URL2 (called from world: Redwall-Ajax)
Function/Sub: OnHyperlink called by trigger
Reason: processing trigger ""
[string "Plugin"]:61: C stack overflow
stack traceback:
[string "Plugin"]:61: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
...
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'Note'
[string "Plugin"]:71: in function <[string "Plugin"]:1>
[C]: in function 'ColourTell'
[string "Plugin"]:68: in function <[string "Plugin"]:1>
Error context in script:
57 : end -- if (doingURL)
58 : i = i + 1
59 : end -- while
60 :
61*: for x, y in ipairs (newstyle) do -- x is the style number, y is the style-data table.
62 : NoteStyle (y.style)
63 : if y.hypernumber ~= nil then
64 : Hyperlink(hyperlinks[y.hypernumber], y.text, "Go to " .. hyperlinks[y.hypernumber]
65 : , "#8daaf0", "#000000", 1)


Then the plugin is effectively useless until I reload the client. Enabling/disabling it doesn't work, the client has to be reloaded completely.

Giving me the error seen below.

Trigger function "OnHyperlink" not found or had a previous error.

Anyway, hopefully this problem hasn't been discussed before and if not I could use some help at everyone's convenience. Thanks in advance.









[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #1 on Thu 01 Oct 2009 08:48 PM (UTC)
Message
Instead of Enable/Disable, you can click on Reinstall to get the plugin to "reboot".

Wihtout knowing what urls, in what scenarios, cause it to barf, we'll have a hard time troubleshooting what's causing it to fail.
[Go to top] top

Posted by Bbfreak   (9 posts)  [Biography] bio
Date Reply #2 on Thu 01 Oct 2009 09:07 PM (UTC)
Message
WillFa said:

Instead of Enable/Disable, you can click on Reinstall to get the plugin to "reboot".

Wihtout knowing what urls, in what scenarios, cause it to barf, we'll have a hard time troubleshooting what's causing it to fail.



Well, I can answer that too. :P This is what crashes the plugin everytime reliably.

"By way of thanks, here's a lovely video Brightwing shared with me yesterday! http://www.youtube.com/watch?v=9T1vfsHYiKY&feature=player_embedded

What happens is this, the plugin fails and then 199 links are sent to the log but don't show in the output. Thus there is 199 blank lines and a quotation mark for say at the end.

Then its the "Trigger function" error everytime I enter a link after that.
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Fri 02 Oct 2009 02:42 AM (UTC)
Message
I tried your test line and it didn't crash, and hyperlinked it OK. Maybe you are using a different version? Try this:

Template:saveplugin=Hyperlink_URL2 To save and install the Hyperlink_URL2 plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Hyperlink_URL2.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Hyperlink_URL2.xml (which you just saved in step 3) as a plugin
  7. Click "Close"



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, 1 April 2006, 12:29 PM -->
<!-- MuClient version 3.73 -->
<muclient>
<plugin 
  name="Hyperlink_URL2" 
  author="Sketch" 
  id="520bc4f29806f7af0017985f" 
  language="Lua" 
  purpose="Makes URLs on a line into hyperlinks." 
  date_written="2006-04-01" 
  date_modified="2009-01-28"
  requires="3.72" 
  version="2.0">

<description trim="y">

<![CDATA[
Detects text starting with HTTP:xxx and makes that part into a hyperlink.
Limits: HTTP:// and the following character must be the same color
]]>
</description>

</plugin>

<!--  Triggers  -->

<triggers>
  <trigger
    enabled="y"
    match="(.*)((https?|mailto)://(?:[\w\d\.\?\/\%#@!&quot;&amp;_]+[/\w\d#]))(.*)$"
    omit_from_output="y"
    ignore_case="y"
    regexp="y"
    script="OnHyperlink"
    sequence="100"
  >
  </trigger>
</triggers>

<!--  Script  -->
<script>
<![CDATA[

function OnHyperlink (name, line, wildcards, styles)
 
  local hyperlinks = {}
  local newstyle = {}
  local i = 1
  local hyperlinkcount = 0
  local doingURL = 0
  
  while i <= table.getn(styles) do -- Doesn't use pairs() because of problems with field-injection.
    if doingURL == 0 then
     -- **** Not a URL **** --
      cut = string.find(styles[i].text, "([hHtTpPsSmMaAiIlLoO]+://[%S]*[%w#/])")
      if cut == nil then -- If there's nothing to cut, copy the whole line
        table.insert(newstyle, {textcolour = styles[i].textcolour
                               ,backcolour = styles[i].backcolour
                               ,style = styles[i].style
                               ,text = styles[i].text})
      else
        table.insert(newstyle, {textcolour = styles[i].textcolour
                               ,backcolour = styles[i].backcolour
                               ,style = styles[i].style
                               ,text = string.sub(styles[i].text, 1, cut - 1)})
        table.insert(styles, i + 1, {textcolour = styles[i].textcolour
                                ,backcolour = styles[i].backcolour
                                ,style = styles[i].style
                                ,text = string.sub(styles[i].text, cut)})
        doingURL = 1
        hyperlinkcount = hyperlinkcount + 1
      end -- if
    else -- **** IS a URL **** --
      -- Search for a URL. If the string is completely a URL...
      -- Jump to the next table field. And keep doing such.
      cut, length, temp = string.find(styles[i].text, "^([%S]*[%w#/])")
      if cut ~= nil then
        if hyperlinks[hyperlinkcount] ~= nil then
          hyperlinks[hyperlinkcount] = hyperlinks[hyperlinkcount] .. temp
        else
          hyperlinks[hyperlinkcount] = temp
        end -- if
        table.insert(newstyle, {textcolour = styles[i].textcolour
                               ,backcolour = styles[i].backcolour
                               ,style = styles[i].style
                               ,text = string.sub(styles[i].text, 1, length)
                               ,hypernumber = hyperlinkcount})
        styles[i].text = string.sub(styles[i].text, length + 1)
        if styles[i].text ~= "" then
          i = i - 1    -- The first hyperlink was cut, so scan the same field for more.
          doingURL = 0
        else
          doingURL = 1
        end
      else 
        doingURL = 0
        i = i - 1
      end -- if (cut)
    end -- if (doingURL)
    i = i + 1
  end -- while
  
  for x, y in ipairs (newstyle) do -- x is the style number, y is the style-data table.
   NoteStyle (y.style)
   if y.hypernumber ~= nil then
     Hyperlink(hyperlinks[y.hypernumber], y.text, "Go to " .. hyperlinks[y.hypernumber]
               , RGBColourToName(y.textcolour), RGBColourToName(y.backcolour), 1)
   else
     ColourTell (RGBColourToName(y.textcolour), RGBColourToName(y.backcolour), y.text)
   end
  end -- while
  Note ("") -- Insert a true newline at the end of the string.
  
end -- of hyperlink
]]>
</script>
</muclient>


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Bbfreak   (9 posts)  [Biography] bio
Date Reply #4 on Fri 02 Oct 2009 03:10 AM (UTC)
Message
Nope, no luck. I did just like you instructed and a new plugin didn't work. Same problem. It only does it when the url wrap around to the next line, or starts on the next line. Otherwise the hyperlink works fine.

I made a copy of the world, removed all triggers, aliases as improbable as it may be that those would be the problem but notta. Still the same problem. o.o

Anyway, I give up for the night so I'm going to bed. Thanks for your efforts just the same.
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sat 03 Oct 2009 03:51 AM (UTC)
Message
Well I can't reproduce it. I set the line width down to 40 so it would wrap, and it works OK, like this:


<24hp 145m 110mv> <#21036> 
say By way of thanks, here's a lovely video Brightwing shared with me yesterday! http://www.youtube.com/watch?v=9T1vfsHYiKY&feature=player_embedded

You say 'By way of thanks, here's a
 lovely video Brightwing shared with me
 yesterday! http://www.youtube.com/watch?v=9T1vfsHY
iKY&feature=player_embedded

'


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,427 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]