Skip to content

Commit

Permalink
urlcopy: More improvements to the pattern matching code. Please repor…
Browse files Browse the repository at this point in the history
…t any regressions (missed URLs) from this change.
  • Loading branch information
funkydude committed Feb 10, 2017
1 parent f681de4 commit c65d370
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions urlcopy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@ BCM.modules[#BCM.modules+1] = function()
-- As of the introduction of the S.E.L.F.I.E camera we now require at least 2 valid letters e.g. yo.hi
local filterFunc = function(_, _, msg, ...)
local newMsg, found = gsub(msg,
" [^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+/[^ \"%^`{}%[%]\\|<>]+",
"|cffffffff|Hbcmurl~%1|h[%1]|h|r"
"( )([^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+/[^ \"%^`{}%[%]\\|<>]+)",
"%1|cffffffff|Hbcmurl~%2|h[%2]|h|r"
)
if found > 0 then return false, newMsg, ... end
newMsg, found = gsub(msg,
"^[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+/[^ \"%^`{}%[%]\\|<>]+",
"^[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+/[^ \"%^`{}%[%]\\|<>]+",
"|cffffffff|Hbcmurl~%1|h[%1]|h|r"
)
if found > 0 then return false, newMsg, ... end
newMsg, found = gsub(msg,
" [^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+",
"|cffffffff|Hbcmurl~%1|h[%1]|h|r"
"( )([^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+)",
"%1|cffffffff|Hbcmurl~%2|h[%2]|h|r"
)
if found > 0 then return false, newMsg, ... end
newMsg, found = gsub(msg,
"^[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%d]+",
"^[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]*%.?[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]%.[^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d][^ %%'%-=%./,\"%^`{}%[%]\\|<>%(%)%*~%d]+",
"|cffffffff|Hbcmurl~%1|h[%1]|h|r"
)
if found > 0 then return false, newMsg, ... end
Expand All @@ -48,8 +49,8 @@ BCM.modules[#BCM.modules+1] = function()
newMsg, found = gsub(msg,
-- This is our mid-sentence IPv4/v6 pattern, we separate the IP patterns into 2 to prevent
-- false positives with linking items, spells, etc.
" %x+[%.:]%x+[%.:]%x+[%.:]%x+[^ \"%^`{}%[%]\\|<>]*",
"|cffffffff|Hbcmurl~%1|h[%1]|h|r"
"( )(%x+[%.:]%x+[%.:]%x+[%.:]%x+[^ \"%^`{}%[%]\\|<>]*)",
"%1|cffffffff|Hbcmurl~%2|h[%2]|h|r"
)
if found > 0 then return false, newMsg, ... end
end
Expand Down

0 comments on commit c65d370

Please sign in to comment.