WeakAuras is apparently tainting* the ChatFrame_OnHyperlinkShow execution path because it overrides its function with a pre-hook. Post-hook would fail because Blizzard's OnHyperlinkShow would choke on unknown links.
Any idea what would be the best way to fix this? What's the standard practice for making custom links that doesn't taint ChatFrame_OnHyperlinkShow?
* The taint causes /tar [playername] to fail whenever [playername] is inserted by Shift-Clicking a player name.
You could hook the ItemRefTooltip's SetHyperlink method instead:
local SetHyperlink = ItemRefTooltip.SetHyperlink
if strsub(link, 1, 4) == "fake" then
print("Fake link clicked!")
This is where unknown link types end up anyway, but doing it this way avoids the error (at least for your custom link type). Not sure if it avoids the taint, but since it doesn't touch anything in the chat frame code, it should be okay.
Looks like I discovered an issue and solved an issue at the same time! Was using it in BadBoy and BCM and only now see that it breaks /tar as the OP described. Replacing it with Phanx's alternative solves the issue.
DBM has been using custom chat links for a very long time and here is how we implemented it. This method shouldn't result in a taint.
We use a normal SetHook call on the OnHyperlinkClick handler of all chat frames* where we handle our links. The whole link text (which gets lost in the call to SetHyperlink) is still available here:
DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, string, button, ...)
local linkType, arg1, arg2, arg3 = strsplit(":", link)
if linkType ~= "DBM" then
if arg1 == "cancel" then
DBM.Bars:CancelBar(link:match("DBM:cancel:(.+):nil$")) -- timer name may contain colons...
(handle other links...)
Now we just have to prevent the default chat frame from doing something stupid (passing the link on to ItemRefTooltip:SetHyperlink())
This is done with a simple hook there which is better for the taint issue:
local old = ItemRefTooltip.SetHyperlink -- we have to hook this function since the default ChatFrame code assumes that all links except for player and channel links are valid arguments for this function
function ItemRefTooltip:SetHyperlink(link, ...)
if link:sub(0, 4) == "DBM:" then
return old(self, link, ...)
*) yes, that means it might have issues with addons that replace the chat frames with something custom, like WIM or something. But our messages that contain links are posted to DEFAULT_CHAT_FRAME only anyways and not to actual chats. So this method might not be useable for everyone.
I have honestly no idea why I wrote it that way back then (I wrote that code during the WotLK beta iirc). The more obvious and robust solution would probably to just hook SetHyperlink and embed all the required information in the link instead of relying on the text (which DBM doesn't anyways, so I wonder why I did it that way...).
Even though your workaround is less elegant than Phanx's solution, it is the only way in which I can fix WeakAura's taint problem without altering the protocol and breaking compatibility, so I think I will go with this instead. ;)
I found it was also necessary to override HandleModifiedItemClick(link, ...) to avoid duplicating the shift-linking code.