!wiki: escape the query before building regex

This commit is contained in:
Janik Kleinhoff 2015-05-07 15:59:48 +00:00
parent a18cfca087
commit 2aa9df07b9

View File

@ -6690,10 +6690,12 @@ def wiki(cli, nick, chan, rest):
if not page: if not page:
cli.notice(nick, "Could not open https://github.com/lykoss/lykos/wiki") cli.notice(nick, "Could not open https://github.com/lykoss/lykos/wiki")
return return
query = re.escape(rest.strip())
#look for exact match first, then for a partial match #look for exact match first, then for a partial match
match = re.search("^##+ ({0})$\r?\n\r?\n^(.*)$".format(rest.strip()), page, re.MULTILINE + re.IGNORECASE) match = re.search("^##+ ({0})$\r?\n\r?\n^(.*)$".format(query), page, re.MULTILINE + re.IGNORECASE)
if not match: if not match:
match = re.search("^##+ ({0}.*)$\r?\n\r?\n^(.*)$".format(rest.strip()), page, re.MULTILINE + re.IGNORECASE) match = re.search("^##+ ({0}.*)$\r?\n\r?\n^(.*)$".format(query), page, re.MULTILINE + re.IGNORECASE)
if not match: if not match:
cli.notice(nick, "Could not find information on that role in https://github.com/lykoss/lykos/wiki") cli.notice(nick, "Could not find information on that role in https://github.com/lykoss/lykos/wiki")
return return