mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-27 21:22:39 +01:00
utils.web: Provide access to the raw httpUrlRe/urlRe strings
Using the compiled regexps for a PluginRegexp method's __doc__ doesn't work.
Closes Sourceforge #2879862
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
(cherry picked from commit 25fc2de643
)
This commit is contained in:
parent
bb4e09886a
commit
f0852a9e45
@ -143,7 +143,7 @@ class ShrinkUrl(callbacks.PluginRegexp):
|
||||
m = irc.reply(s, prefixNick=False)
|
||||
m.tag('shrunken')
|
||||
shrinkSnarfer = urlSnarfer(shrinkSnarfer)
|
||||
shrinkSnarfer.__doc__ = utils.web.httpUrlRe
|
||||
shrinkSnarfer.__doc__ = utils.web._httpUrlRe
|
||||
|
||||
def _getLnUrl(self, url):
|
||||
url = utils.web.urlquote(url)
|
||||
|
@ -105,7 +105,7 @@ class Web(callbacks.PluginRegexp):
|
||||
s = format('Title: %s (at %s)', title, domain)
|
||||
irc.reply(s, prefixNick=False)
|
||||
titleSnarfer = urlSnarfer(titleSnarfer)
|
||||
titleSnarfer.__doc__ = utils.web.httpUrlRe
|
||||
titleSnarfer.__doc__ = utils.web._httpUrlRe
|
||||
|
||||
def headers(self, irc, msg, args, url):
|
||||
"""<url>
|
||||
|
@ -45,15 +45,16 @@ urlunquote = urllib.unquote
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
octet = r'(?:2(?:[0-4]\d|5[0-5])|1\d\d|\d{1,2})'
|
||||
ipAddr = r'%s(?:\.%s){3}' % (octet, octet)
|
||||
_octet = r'(?:2(?:[0-4]\d|5[0-5])|1\d\d|\d{1,2})'
|
||||
_ipAddr = r'%s(?:\.%s){3}' % (_octet, _octet)
|
||||
# Base domain regex off RFC 1034 and 1738
|
||||
label = r'[0-9a-z][-0-9a-z]*[0-9a-z]?'
|
||||
domain = r'%s(?:\.%s)*\.[a-z][-0-9a-z]*[a-z]?' % (label, label)
|
||||
urlRe = re.compile(r'(\w+://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)'
|
||||
% (domain, ipAddr), re.I)
|
||||
httpUrlRe = re.compile(r'(https?://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)'
|
||||
% (domain, ipAddr), re.I)
|
||||
_label = r'[0-9a-z][-0-9a-z]*[0-9a-z]?'
|
||||
_domain = r'%s(?:\.%s)*\.[a-z][-0-9a-z]*[a-z]?' % (_label, _label)
|
||||
_urlRe = r'(\w+://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)' % (_domain, _ipAddr)
|
||||
urlRe = re.compile(_urlRe, re.I)
|
||||
_httpUrlRe = r'(https?://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)' % (_domain,
|
||||
_ipAddr)
|
||||
httpUrlRe = re.compile(_httpUrlRe, re.I)
|
||||
|
||||
REFUSED = 'Connection refused.'
|
||||
TIMED_OUT = 'Connection timed out.'
|
||||
|
Loading…
Reference in New Issue
Block a user