mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +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 = irc.reply(s, prefixNick=False)
|
||||||
m.tag('shrunken')
|
m.tag('shrunken')
|
||||||
shrinkSnarfer = urlSnarfer(shrinkSnarfer)
|
shrinkSnarfer = urlSnarfer(shrinkSnarfer)
|
||||||
shrinkSnarfer.__doc__ = utils.web.httpUrlRe
|
shrinkSnarfer.__doc__ = utils.web._httpUrlRe
|
||||||
|
|
||||||
def _getLnUrl(self, url):
|
def _getLnUrl(self, url):
|
||||||
url = utils.web.urlquote(url)
|
url = utils.web.urlquote(url)
|
||||||
|
@ -105,7 +105,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
s = format('Title: %s (at %s)', title, domain)
|
s = format('Title: %s (at %s)', title, domain)
|
||||||
irc.reply(s, prefixNick=False)
|
irc.reply(s, prefixNick=False)
|
||||||
titleSnarfer = urlSnarfer(titleSnarfer)
|
titleSnarfer = urlSnarfer(titleSnarfer)
|
||||||
titleSnarfer.__doc__ = utils.web.httpUrlRe
|
titleSnarfer.__doc__ = utils.web._httpUrlRe
|
||||||
|
|
||||||
def headers(self, irc, msg, args, url):
|
def headers(self, irc, msg, args, url):
|
||||||
"""<url>
|
"""<url>
|
||||||
|
@ -45,15 +45,16 @@ urlunquote = urllib.unquote
|
|||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
octet = r'(?:2(?:[0-4]\d|5[0-5])|1\d\d|\d{1,2})'
|
_octet = r'(?:2(?:[0-4]\d|5[0-5])|1\d\d|\d{1,2})'
|
||||||
ipAddr = r'%s(?:\.%s){3}' % (octet, octet)
|
_ipAddr = r'%s(?:\.%s){3}' % (_octet, _octet)
|
||||||
# Base domain regex off RFC 1034 and 1738
|
# Base domain regex off RFC 1034 and 1738
|
||||||
label = r'[0-9a-z][-0-9a-z]*[0-9a-z]?'
|
_label = r'[0-9a-z][-0-9a-z]*[0-9a-z]?'
|
||||||
domain = r'%s(?:\.%s)*\.[a-z][-0-9a-z]*[a-z]?' % (label, label)
|
_domain = r'%s(?:\.%s)*\.[a-z][-0-9a-z]*[a-z]?' % (_label, _label)
|
||||||
urlRe = re.compile(r'(\w+://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)'
|
_urlRe = r'(\w+://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)' % (_domain, _ipAddr)
|
||||||
% (domain, ipAddr), re.I)
|
urlRe = re.compile(_urlRe, re.I)
|
||||||
httpUrlRe = re.compile(r'(https?://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)'
|
_httpUrlRe = r'(https?://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)' % (_domain,
|
||||||
% (domain, ipAddr), re.I)
|
_ipAddr)
|
||||||
|
httpUrlRe = re.compile(_httpUrlRe, re.I)
|
||||||
|
|
||||||
REFUSED = 'Connection refused.'
|
REFUSED = 'Connection refused.'
|
||||||
TIMED_OUT = 'Connection timed out.'
|
TIMED_OUT = 'Connection timed out.'
|
||||||
|
Loading…
Reference in New Issue
Block a user