Fix escaping html

This commit is contained in:
Ceda EI 2019-02-26 18:07:14 +05:30
parent 030276a23f
commit 095e7791d3
1 changed files with 7 additions and 0 deletions

7
bot.py
View File

@ -9,6 +9,7 @@ from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, \
RegexHandler RegexHandler
import signal import signal
import sys import sys
import re
try: try:
import config import config
@ -20,6 +21,11 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - \
%(message)s', level=logging.INFO) %(message)s', level=logging.INFO)
def escape_html(message):
return re.sub("<", "&lt;",
re.sub("&", "&amp;", message))
def start(bot, update): def start(bot, update):
chat_id = update.message.chat_id chat_id = update.message.chat_id
name = str(update.message.from_user.first_name) name = str(update.message.from_user.first_name)
@ -151,6 +157,7 @@ def send_status(bot, update, player, prefix=""):
name = str(update.message.from_user.first_name) name = str(update.message.from_user.first_name)
if update.message.from_user.last_name: if update.message.from_user.last_name:
name += " " + str(update.message.from_user.last_name) name += " " + str(update.message.from_user.last_name)
name = escape_html(name)
points = player.get_points() points = player.get_points()
total_quests = len(player.get_quests(None)) total_quests = len(player.get_quests(None))
completed_quests = len(player.get_quests(1)) completed_quests = len(player.get_quests(1))