aboutsummaryrefslogtreecommitdiff
path: root/irc
diff options
context:
space:
mode:
authorKubilay Kocak <koobs@FreeBSD.org>2019-10-01 03:47:16 +0000
committerKubilay Kocak <koobs@FreeBSD.org>2019-10-01 03:47:16 +0000
commit4c6b47d49f526e4aa085f3d82bef3b2910453e64 (patch)
tree5f2a13af7418dbb9898e431a2046f8500c3843b7 /irc
parent41e4b588f578d9f99a7bbdfde7f7756773360034 (diff)
downloadports-4c6b47d49f526e4aa085f3d82bef3b2910453e64.tar.gz
ports-4c6b47d49f526e4aa085f3d82bef3b2910453e64.zip
Notes
Diffstat (limited to 'irc')
-rw-r--r--irc/py-limnoria/Makefile2
-rw-r--r--irc/py-limnoria/files/patch-plugins_Web_plugin.py62
2 files changed, 63 insertions, 1 deletions
diff --git a/irc/py-limnoria/Makefile b/irc/py-limnoria/Makefile
index 6f4ad491234b..321c9a3fe4ad 100644
--- a/irc/py-limnoria/Makefile
+++ b/irc/py-limnoria/Makefile
@@ -3,7 +3,7 @@
PORTNAME= limnoria
PORTVERSION= 2018.09.09
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= irc python
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
diff --git a/irc/py-limnoria/files/patch-plugins_Web_plugin.py b/irc/py-limnoria/files/patch-plugins_Web_plugin.py
new file mode 100644
index 000000000000..ffe58591527f
--- /dev/null
+++ b/irc/py-limnoria/files/patch-plugins_Web_plugin.py
@@ -0,0 +1,62 @@
+# https://github.com/ProgVal/Limnoria/pull/1371
+# https://github.com/ProgVal/Limnoria/issues/1362
+# https://github.com/ProgVal/Limnoria/issues/1359
+
+--- plugins/Web/plugin.py.orig 2019-09-29 03:00:58 UTC
++++ plugins/Web/plugin.py
+@@ -149,32 +149,31 @@ class Web(callbacks.PluginRegexp):
+ def getTitle(self, irc, url, raiseErrors):
+ size = conf.supybot.protocols.http.peekSize()
+ timeout = self.registryValue('timeout')
+- (target, text) = utils.web.getUrlTargetAndContent(url, size=size,
+- timeout=timeout)
+ try:
+- text = text.decode(utils.web.getEncoding(text) or 'utf8',
+- 'replace')
+- except UnicodeDecodeError:
+- pass
+- parser = Title()
+- if minisix.PY3 and isinstance(text, bytes):
+- if raiseErrors:
+- irc.error(_('Could not guess the page\'s encoding. (Try '
+- 'installing python-charade.)'), Raise=True)
++ (target, text) = utils.web.getUrlTargetAndContent(url, size=size,timeout=timeout)
++ encoding = utils.web.getEncoding(text)
++ if encoding is None: # Condition if charade not installed
++ self.log.info('Web plugin TitleSnarfer: Could not guess the page\'s'
++ ' encoding. (Try installing python-charade.)')
++ encoding = 'utf-8' # Assume UTF-8 and replace unknown chars to the UTF-8 codec for U+FFFD in the next hop
++ text = text.decode(utils.web.getEncoding(text) or 'utf-8','replace')
++ parser = Title()
++ try:
++ parser.feed(text)
++ except:
++ parser = Title()
++ parser.feed(bytes(text)) # Explicitly pack to bytes in encoding errors for (more) python2 compatibility
++ parser.close()
++ title = utils.str.normalizeWhitespace(''.join(parser.data).strip())
++ if title:
++ return (target, title)
+ else:
+- return None
+- parser.feed(text)
+- parser.close()
+- title = utils.str.normalizeWhitespace(''.join(parser.data).strip())
+- if title:
+- return (target, title)
+- elif raiseErrors:
+- if len(text) < size:
+- irc.error(_('That URL appears to have no HTML title.'),
+- Raise=True)
+- else:
+- irc.error(format(_('That URL appears to have no HTML title '
+- 'within the first %S.'), size), Raise=True)
++ if len(text) < size:
++ self.log.info('Web plugin TitleSnarfer: <' + url + '> appears to have no HTML title.')
++ else:
++ self.log.info('Web plugin TitleSnarfer: Could not retrieve title of <' + url + '>')
++ except Exception as e:
++ self.log.info('Web plugin TitleSnarfer: <' + str(e) + '> while trying to process <' + url +'>')
+
+ @fetch_sandbox
+ def titleSnarfer(self, irc, msg, match):