svn commit: r513446 - in head/irc/py-limnoria: . files
Kubilay Kocak
koobs at FreeBSD.org
Tue Oct 1 03:47:17 UTC 2019
Author: koobs
Date: Tue Oct 1 03:47:16 2019
New Revision: 513446
URL: https://svnweb.freebsd.org/changeset/ports/513446
Log:
irc/py-limnoria: Backport Web plugin bugfixes
Backport fixes for the Web plugin [1][2][3].
[1] https://github.com/ProgVal/Limnoria/pull/1371
[2] https://github.com/ProgVal/Limnoria/issues/1362
[3] https://github.com/ProgVal/Limnoria/issues/1359
Submitted by: DanDare (GitHub: Rodrigo-NH, via IRC)
Added:
head/irc/py-limnoria/files/
head/irc/py-limnoria/files/patch-plugins_Web_plugin.py (contents, props changed)
Modified:
head/irc/py-limnoria/Makefile
Modified: head/irc/py-limnoria/Makefile
==============================================================================
--- head/irc/py-limnoria/Makefile Tue Oct 1 03:23:17 2019 (r513445)
+++ head/irc/py-limnoria/Makefile Tue Oct 1 03:47:16 2019 (r513446)
@@ -3,7 +3,7 @@
PORTNAME= limnoria
PORTVERSION= 2018.09.09
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= irc python
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
Added: head/irc/py-limnoria/files/patch-plugins_Web_plugin.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/irc/py-limnoria/files/patch-plugins_Web_plugin.py Tue Oct 1 03:47:16 2019 (r513446)
@@ -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):
More information about the svn-ports-head
mailing list