From db05081ff691b4cb9073ea3e94716914a531052f Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 25 Aug 2021 23:28:25 +0200 Subject: [PATCH] commands: fix _checkUrl --- plugins/Web/test.py | 2 ++ src/commands.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/Web/test.py b/plugins/Web/test.py index e3d88459e..ea8686127 100644 --- a/plugins/Web/test.py +++ b/plugins/Web/test.py @@ -179,6 +179,8 @@ class WebTestCase(ChannelPluginTestCase): def testFetchIri(self): self.assertRegexp('fetch http://café.example.org/', 'Error: .*is not a valid') + self.assertRegexp('fetch http://example.org/café', + 'Error: .*is not a valid') # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/src/commands.py b/src/commands.py index 0be91b1c7..ecc9149b8 100644 --- a/src/commands.py +++ b/src/commands.py @@ -667,15 +667,15 @@ def getGlob(irc, msg, args, state): glob = '*%s*' % glob state.args.append(glob) -def _checkUrl(url): +def _checkUrl(state, url): try: - args[0].encode('ascii') + url.encode('ascii') except UnicodeEncodeError: - state.errorInvalid(_('url'), args[0]) + state.errorInvalid(_('url'), url) def getUrl(irc, msg, args, state): if utils.web.urlRe.match(args[0]): - _checkUrl(args[0]) + _checkUrl(state, args[0]) state.args.append(args.pop(0)) else: state.errorInvalid(_('url'), args[0]) @@ -694,10 +694,10 @@ def getEmail(irc, msg, args, state): def getHttpUrl(irc, msg, args, state): if utils.web.httpUrlRe.match(args[0]): - _checkUrl(args[0]) + _checkUrl(state, args[0]) state.args.append(args.pop(0)) elif utils.web.httpUrlRe.match('http://' + args[0]): - _checkUrl('http://' + args[0]) + _checkUrl(state, 'http://' + args[0]) state.args.append('http://' + args.pop(0)) else: state.errorInvalid(_('http url'), args[0])