From 9a426ff97fae32ad6318a18370c407fec2c2d587 Mon Sep 17 00:00:00 2001 From: Yuriy Vilks Date: Fri, 22 Sep 2023 13:19:22 +0300 Subject: [PATCH] [Notifier] Telegram Bridge add escaping for \ --- .../Component/Notifier/Bridge/Telegram/TelegramTransport.php | 3 +-- .../Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php index 9bb25bee5f587..af7a31b38f559 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Notifier\Bridge\Telegram; -use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\ChatMessage; @@ -74,7 +73,7 @@ protected function doSend(MessageInterface $message): SentMessage if (!isset($options['parse_mode']) || TelegramOptions::PARSE_MODE_MARKDOWN_V2 === $options['parse_mode']) { $options['parse_mode'] = TelegramOptions::PARSE_MODE_MARKDOWN_V2; - $options['text'] = preg_replace('/([_*\[\]()~`>#+\-=|{}.!])/', '\\\\$1', $message->getSubject()); + $options['text'] = preg_replace('/([_*\[\]()~`>#+\-=|{}.!\\\\])/', '\\\\$1', $message->getSubject()); } if (isset($options['photo'])) { diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php index 83251aa4f9c29..0ea7ed6e95175 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php @@ -316,7 +316,7 @@ public function testSendWithMarkdownShouldEscapeSpecialCharacters() $expectedBody = [ 'chat_id' => 'testChannel', - 'text' => 'I contain special characters \_ \* \[ \] \( \) \~ \` \> \# \+ \- \= \| \{ \} \. \! to send\.', + 'text' => 'I contain special characters \_ \* \[ \] \( \) \~ \` \> \# \+ \- \= \| \{ \} \. \! \\\\ to send\.', 'parse_mode' => 'MarkdownV2', ]; @@ -328,7 +328,7 @@ public function testSendWithMarkdownShouldEscapeSpecialCharacters() $transport = self::createTransport($client, 'testChannel'); - $transport->send(new ChatMessage('I contain special characters _ * [ ] ( ) ~ ` > # + - = | { } . ! to send.')); + $transport->send(new ChatMessage('I contain special characters _ * [ ] ( ) ~ ` > # + - = | { } . ! \\ to send.')); } public function testSendPhotoWithOptions() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy