Thread Tools Display Modes
03-20-15, 09:44 AM   #1
VikingP
A Deviate Faerie Dragon
Join Date: Aug 2014
Posts: 10
Twitter bug

Im using a UI that it's not been updated, but i would like to keep using it.
So looking for some help to see if i can fix this.
Have little lua skills. Tested a few things without any luck.
It's ShestakUI, https://github.com/Shestak/ShestakUI

Here is how the copyurl.lua looks like:
Lua Code:
  1. local T, C, L, _ = unpack(select(2, ...))
  2. if C.chat.enable ~= true then return end
  3.  
  4. ----------------------------------------------------------------------------------------
  5. --  Copy url from chat(module from Gibberish by p3lim)
  6. ----------------------------------------------------------------------------------------
  7. local patterns = {
  8.     "(https://%S+)",
  9.     "(http://%S+)",
  10.     "(www%.%S+)",
  11.     "(%d+%.%d+%.%d+%.%d+:?%d*)"
  12. }
  13.  
  14. for _, event in pairs({
  15.     "CHAT_MSG_GUILD",
  16.     "CHAT_MSG_PARTY",
  17.     "CHAT_MSG_PARTY_LEADER",
  18.     "CHAT_MSG_RAID",
  19.     "CHAT_MSG_RAID_LEADER",
  20.     "CHAT_MSG_CHANNEL",
  21.     "CHAT_MSG_WHISPER",
  22.     "CHAT_MSG_BN_WHISPER",
  23.     "CHAT_MSG_SAY",
  24.     "CHAT_MSG_INSTANCE_CHAT",
  25.     "CHAT_MSG_INSTANCE_CHAT_LEADER"
  26. }) do
  27.     ChatFrame_AddMessageEventFilter(event, function(self, event, str, ...)
  28.         for _, pattern in pairs(patterns) do
  29.             local result, match = string.gsub(str, pattern, "|cff00FF00|Hurl:%1|h[%1]|h|r")
  30.             if match > 0 then
  31.                 return false, result, ...
  32.             end
  33.         end
  34.     end)
  35. end
  36.  
  37. local orig = SetItemRef
  38. function SetItemRef(link, str, ...)
  39.     if string.sub(link, 1, 3) ~= "url" then return orig(link, str, ...) end
  40.  
  41.     local editbox = ChatEdit_ChooseBoxForSend()
  42.     ChatEdit_ActivateChat(editbox)
  43.     editbox:Insert(string.sub(link, 5))
  44.     editbox:HighlightText()
  45. end

Error:
Lua Code:
  1. Message: ...rface\AddOns\Blizzard_SocialUI\Blizzard_SocialUI.lua:119: Attempt to access forbidden object from code tainted by an AddOn
  2. Time: 03/20/15 16:44:01
  3. Count: 13
  4. Stack: [C]: in function `Show'
  5. ...rface\AddOns\Blizzard_SocialUI\Blizzard_SocialUI.lua:119: in function `SocialPostFrame_ShowScreenshot'
  6. Interface\FrameXML\ItemRef.lua:249: in function <Interface\FrameXML\ItemRef.lua:1>
  7. (tail call): ?
  8. (tail call): ?
  9. ...ace\AddOns\Blizzard_CombatLog\Blizzard_CombatLog.lua:3602: in function `SetItemRef'
  10. Interface\FrameXML\ChatFrame.lua:3374: in function `ChatFrame_OnHyperlinkShow'
  11. [string "*:OnHyperlinkClick"]:1: in function <[string "*:OnHyperlinkClick"]:1>
  12.  
  13. Locals: (*temporary) = SocialPostFrame {
  14.  0 = <userdata>
  15.  TitleText = <unnamed> {
  16.  }
  17.  RightBorder = <unnamed> {
  18.  }
  19.  LeftBorder = <unnamed> {
  20.  }
  21.  ImageFrame = <unnamed> {
  22.  }
  23.  ShareIcon = <unnamed> {
  24.  }
  25.  EdgeArt-Right = <unnamed> {
  26.  }
  27.  TopRightCorner = <unnamed> {
  28.  }
  29.  TopLeftCorner = <unnamed> {
  30.  }
  31.  Bg = <unnamed> {
  32.  }
  33.  ScreenshotButton = <unnamed> {
  34.  }
  35.  TopBorder = <unnamed> {
  36.  }
  37.  PostButton = <unnamed> {
  38.  }
  39.  TopTileStreaks = <unnamed> {
  40.  }
  41.  TitleBg = <unnamed> {
  42.  }
  43.  BottomBorder = <unnamed> {
  44.  }
  45.  BotRightCorner = <unnamed> {
  46.  }
  47.  BorderFrame = <unnamed> {
  48.  }
  49.  SocialMessageFrame = SocialPostFrameMessageFrame {
  50.  }
  51.  CloseButton = <unnamed> {
  52.  }
  53.  Title = <unnamed> {
  54.  }
  55.  AchievementButton = <unnamed> {
  56.  }
  57.  BotLeftCorner = <unnamed> {
  58.  }
  59.  DragBar = <unnamed> {
  60.  }
  61.  EdgeArt-Left = <unnamed> {
  62.  }
  63.  ItemButton = <unnamed> {
  64.  }
  65. }

Any help or tip would be nice
  Reply With Quote
03-20-15, 10:04 AM   #2
Munglunch
Premium Member
 
Munglunch's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 34
Whats happening is that the older method of parsing chat strings for hyperlinks has no protection from the new "share" linktype.

Try this

In your code:
Lua Code:
  1. for _, event in pairs({
  2.     "CHAT_MSG_GUILD",
  3.     "CHAT_MSG_PARTY",
  4.     "CHAT_MSG_PARTY_LEADER",
  5.     "CHAT_MSG_RAID",
  6.     "CHAT_MSG_RAID_LEADER",
  7.     "CHAT_MSG_CHANNEL",
  8.     "CHAT_MSG_WHISPER",
  9.     "CHAT_MSG_BN_WHISPER",
  10.     "CHAT_MSG_SAY",
  11.     "CHAT_MSG_INSTANCE_CHAT",
  12.     "CHAT_MSG_INSTANCE_CHAT_LEADER"
  13. }) do
  14.     ChatFrame_AddMessageEventFilter(event, function(self, event, str, ...)
  15.         for _, pattern in pairs(patterns) do
  16.             local result, match = string.gsub(str, pattern, "|cff00FF00|Hurl:%1|h[%1]|h|r")
  17.             if match > 0 then
  18.                 return false, result, ...
  19.             end
  20.         end
  21.     end)
  22. end

You need to add this
Lua Code:
  1. if(str:find("%pHshare%p+")) then return end

So re-written it will look like this:

Lua Code:
  1. for _, event in pairs({
  2.     "CHAT_MSG_GUILD",
  3.     "CHAT_MSG_PARTY",
  4.     "CHAT_MSG_PARTY_LEADER",
  5.     "CHAT_MSG_RAID",
  6.     "CHAT_MSG_RAID_LEADER",
  7.     "CHAT_MSG_CHANNEL",
  8.     "CHAT_MSG_WHISPER",
  9.     "CHAT_MSG_BN_WHISPER",
  10.     "CHAT_MSG_SAY",
  11.     "CHAT_MSG_INSTANCE_CHAT",
  12.     "CHAT_MSG_INSTANCE_CHAT_LEADER"
  13. }) do
  14.     ChatFrame_AddMessageEventFilter(event, function(self, event, str, ...)
  15.         if(str:find("%pHshare%p+")) then return end
  16.         for _, pattern in pairs(patterns) do
  17.             local result, match = string.gsub(str, pattern, "|cff00FF00|Hurl:%1|h[%1]|h|r")
  18.             if match > 0 then
  19.                 return false, result, ...
  20.             end
  21.         end
  22.     end)
  23. end
  Reply With Quote
03-20-15, 12:52 PM   #3
VikingP
A Deviate Faerie Dragon
Join Date: Aug 2014
Posts: 10
Thank you for trying, but that didn't solve it. Still same error.
  Reply With Quote
03-20-15, 02:08 PM   #4
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Munglunch View Post
Lua Code:
  1. for _, event in pairs({...}) do
  2.     ChatFrame_AddMessageEventFilter(event, function(self, event, str, ...)
  3.         if(str:find("%pHshare%p+")) then return end
Yeah...no. Terminating the entire iteration when finding "share" won't do anything remotely bad...
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-20-15, 04:28 PM   #5
VikingP
A Deviate Faerie Dragon
Join Date: Aug 2014
Posts: 10
Originally Posted by Torhal View Post
Yeah...no. Terminating the entire iteration when finding "share" won't do anything remotely bad...
Joke? didn't get that 1
  Reply With Quote
03-20-15, 05:20 PM   #6
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by VikingP View Post
Joke? didn't get that 1
I was just pointing out that using the solution you were given would actually break things worse than what they are.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-20-15, 07:08 PM   #7
VikingP
A Deviate Faerie Dragon
Join Date: Aug 2014
Posts: 10
Originally Posted by Torhal View Post
I was just pointing out that using the solution you were given would actually break things worse than what they are.
Ahh
Above my skills Credit for trying atleast!
  Reply With Quote
03-20-15, 07:36 PM   #8
Munglunch
Premium Member
 
Munglunch's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 34
Originally Posted by Torhal View Post
I was just pointing out that using the solution you were given would actually break things worse than what they are.
That's weird, I could have sworn that in the native function ChatFrame_MessageEventHandler (ChatFrame.lua @line 2913), while parsing/executing chat filters (ChatFrame.lua @line 2929) will initially check the first return value for anything that evaluates (ie... anything OTHER than false or nil).

...But that would mean that my solution would cause NO HARM AT ALL, ..... so ... that can't be right. Right?

Actually, posting anything other than a possible solution to the problem presented is in fact making "things worse than what they are".

Last edited by Munglunch : 03-20-15 at 07:48 PM.
  Reply With Quote
03-20-15, 08:28 PM   #9
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
I don't have the solution, because I didn't fully look at the code, but when you're iterating over things to set them up, terminating the iteration altogether instead of gracefully handling it will lead to a bad state. So, if "share" was found for "CHAT_MSG_PARTY" the others that came after would never have the filter applied, even if they should. That's not causing no harm at all, it is in fact making things worse. I'm not trying to pick a fight here; I was merely pointing out that there was a logic error in case you wanted to re-address.

I'll refrain from being helpful now.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-20-15, 11:12 PM   #10
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Wait....... WoW has twitter now? Is this recent?

/derailed
__________________
Tweets YouTube Website
  Reply With Quote
03-21-15, 04:33 AM   #11
VikingP
A Deviate Faerie Dragon
Join Date: Aug 2014
Posts: 10
Originally Posted by 10leej View Post
Wait....... WoW has twitter now? Is this recent?

/derailed
Since 6.1
http://www.wowhead.com/guide=2957/how-to-tweet-in-game
  Reply With Quote
03-21-15, 06:05 AM   #12
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Torhal View Post
I don't have the solution, because I didn't fully look at the code, but when you're iterating over things to set them up, terminating the iteration altogether instead of gracefully handling it will lead to a bad state. So, if "share" was found for "CHAT_MSG_PARTY" the others that came after would never have the filter applied, even if they should. That's not causing no harm at all, it is in fact making things worse. I'm not trying to pick a fight here; I was merely pointing out that there was a logic error in case you wanted to re-address.

I'll refrain from being helpful now.
The return is inside the function!
__________________
Grab your sword and fight the Horde!
  Reply With Quote
03-21-15, 12:38 PM   #13
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Lombra View Post
The return is inside the function!
And this is why I generally don't write replies when I just skim code. Yay.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-21-15, 04:08 PM   #14
Munglunch
Premium Member
 
Munglunch's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 34
Originally Posted by Torhal View Post
And this is why I generally don't write replies when I just skim code. Yay.
Torhal, I'm sorry for the way that I worded that post, it was unnecessary and unprofessional.

... And that is why I generally don't write replies when I am in a bad mood. Bad Mung!
  Reply With Quote
03-21-15, 06:13 PM   #15
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Munglunch View Post
Torhal, I'm sorry for the way that I worded that post, it was unnecessary and unprofessional.

... And that is why I generally don't write replies when I am in a bad mood. Bad Mung!
It's all good. I still have all my limbs. I think. Damn it!
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-21-15, 08:21 PM   #16
VikingP
A Deviate Faerie Dragon
Join Date: Aug 2014
Posts: 10
Nice of you all to kiss and make up

After 4 hours i found a solution (error was also caused from 2 other files altinvite and multitip)

Here is how it ended up.

Lua Code:
  1. local T, C, L, _ = unpack(select(2, ...))
  2. if C.chat.enable ~= true then return end
  3.  
  4. ----------------------------------------------------------------------------------------
  5. --  Copy url from chat(module from Gibberish by p3lim)
  6. ----------------------------------------------------------------------------------------
  7. local patterns = {
  8.     "(https://%S+)",
  9.     "(http://%S+)",
  10.     "(www%.%S+)",
  11.     "(%d+%.%d+%.%d+%.%d+:?%d*)"
  12. }
  13.  
  14. for _, event in pairs({
  15.     "CHAT_MSG_GUILD",
  16.     "CHAT_MSG_PARTY",
  17.     "CHAT_MSG_PARTY_LEADER",
  18.     "CHAT_MSG_RAID",
  19.     "CHAT_MSG_RAID_LEADER",
  20.     "CHAT_MSG_CHANNEL",
  21.     "CHAT_MSG_WHISPER",
  22.     "CHAT_MSG_BN_WHISPER",
  23.     "CHAT_MSG_SAY",
  24.     "CHAT_MSG_INSTANCE_CHAT",
  25.     "CHAT_MSG_INSTANCE_CHAT_LEADER",
  26.     "CHAT_MSG_BATTLEGROUND_LEADER",
  27.     "CHAT_MSG_BN_CONVERSATION",
  28.     "CHAT_MSG_RAID_WARNING",
  29.     "CHAT_MSG_OFFICER",
  30.     "CHAT_MSG_BATTLEGROUND",
  31.     "CHAT_MSG_YELL"
  32. }) do
  33.     ChatFrame_AddMessageEventFilter(event, function(self, event, str, ...)
  34.         for _, pattern in pairs(patterns) do
  35.             local result, match = string.gsub(str, pattern, "|cff00FF00|Hurl:%1|h[%1]|h|r")
  36.             if match > 0 then
  37.                 return false, result, ...
  38.             end
  39.         end
  40.     end)
  41. end
  42.  
  43. local SetHyperlink = _G.ItemRefTooltip.SetHyperlink
  44. function _G.ItemRefTooltip:SetHyperlink(link, ...)
  45.     if link and (strsub(link, 1, 3) == "url") then
  46.         local url = strsub(link, 5)
  47.        
  48.         local editbox = ChatEdit_ChooseBoxForSend()
  49.         ChatEdit_ActivateChat(editbox)
  50.         editbox:Insert(string.sub(link, 5))
  51.         editbox:HighlightText()
  52.        
  53.         return
  54.      end
  55.      
  56.      SetHyperlink(self, link, ...)
  57. end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Twitter bug


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off