From d0534aedbff06a1134438aaa335e552a63520420 Mon Sep 17 00:00:00 2001 From: shoko <270575765+shokollm@users.noreply.github.com> Date: Wed, 25 Mar 2026 11:42:42 +0000 Subject: [PATCH] Fix #5: HTML injection in Telegram messages Add escape_html() function to prevent HTML injection in Telegram parse_mode=HTML messages. Apply escaping to event titles inserted into tags in send_to_telegram(). - Add escape_html() using stdlib html.escape() - Escape match event titles (line 648) and non-match titles (line 676) - Add TestHtmlInjection with 2 tests proving fix: - - Team A vs Team B", + "slug": "test-event", + "startTime": "2027-03-26T12:00:00Z", + "markets": [{ + "sportsMarketType": "moneyline", + "outcomes": '["Team A", "Team B"]', + "outcomePrices": "[0.55, 0.45]", + "bestBid": "0.54", + "bestAsk": "0.56", + "volume": 50000, + "acceptingOrders": True, + "closed": False, + }], + } + + from browse import send_to_telegram + send_to_telegram([malicious_event], [], "Counter Strike") + + # Check what was passed to send_telegram_message + self.assertEqual(mock_send_msg.called, True) + sent_text = mock_send_msg.call_args[0][2] # text arg (3rd positional) + + # AFTER FIX: