PortLookup: stop parsing notes, the format keeps on changing

(cherry picked from commit 7fd7b98bc37205162e1cc87f55726dcb04e33438)
This commit is contained in:
James Lu 2018-04-12 11:07:19 -07:00
parent 2ebe1800c6
commit 13224a621a
2 changed files with 2 additions and 8 deletions

View File

@ -96,14 +96,8 @@ class PortLookup(callbacks.Plugin):
# Remove inline citations (text[1][2][3]), citation needed tags, etc. # Remove inline citations (text[1][2][3]), citation needed tags, etc.
text = re.sub('\[.*?]', '', text) text = re.sub('\[.*?]', '', text)
# List the port notes (tags such as "Official", "TCP", "UDP", etc.)
# This is every <td> tag except the 4th one, which is the description parsed
# above.
notes = [t.text.strip() for t in tds[:3]+tds[4:] if '?' not in t]
notes = '; '.join(filter(None, notes))
# Remove \n, etc. in fields to prevent output corruption. # Remove \n, etc. in fields to prevent output corruption.
s = utils.str.normalizeWhitespace('%s [%s]' % (ircutils.bold(text), notes)) s = utils.str.normalizeWhitespace('%s (%s)' % (ircutils.bold(text), portnum))
results.append(s) results.append(s)
if results: if results:
irc.reply(format('%s: %L', ircutils.bold(ircutils.underline(port)), results)) irc.reply(format('%s: %L', ircutils.bold(ircutils.underline(port)), results))

View File

@ -35,7 +35,7 @@ class PortLookupTestCase(PluginTestCase):
plugins = ('PortLookup',) plugins = ('PortLookup',)
def testPort(self): def testPort(self):
self.assertRegexp('port 22', 'SSH.*?TCP.*?Official') self.assertRegexp('port 22', 'SSH')
# Some entries in the list are defined as port ranges (i.e. # Some entries in the list are defined as port ranges (i.e.
# 6665-6669); we have to split them manually. # 6665-6669); we have to split them manually.