Hyperlink_URL2 Trouble

Posted by Bbfreak on Thu 01 Oct 2009 07:16 PM — 6 posts, 25,823 views.

#0
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.









USA #1
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.
#2
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.
Australia Forum Administrator #3
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 the code below (in the code box) to the Clipboard
  2. Open a text editor (such as Notepad) and paste the plugin code into it
  3. Save to disk on your PC, preferably in your plugins directory, as Hyperlink_URL2.xml
    • The "plugins" directory is usually under the "worlds" directory inside where you installed MUSHclient.
  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"
  8. Save your world file, so that the plugin loads next time you open it.



<?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>

#4
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.
Australia Forum Administrator #5
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

'