Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9a426ff

Browse filesBrowse files
committed
[Notifier] Telegram Bridge add escaping for \
1 parent 93afb42 commit 9a426ff
Copy full SHA for 9a426ff

File tree

Expand file treeCollapse file tree

2 files changed

+3
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-4
lines changed

‎src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Telegram;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
1514
use Symfony\Component\Notifier\Exception\TransportException;
1615
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1716
use Symfony\Component\Notifier\Message\ChatMessage;
@@ -74,7 +73,7 @@ protected function doSend(MessageInterface $message): SentMessage
7473

7574
if (!isset($options['parse_mode']) || TelegramOptions::PARSE_MODE_MARKDOWN_V2 === $options['parse_mode']) {
7675
$options['parse_mode'] = TelegramOptions::PARSE_MODE_MARKDOWN_V2;
77-
$options['text'] = preg_replace('/([_*\[\]()~`>#+\-=|{}.!])/', '\\\\$1', $message->getSubject());
76+
$options['text'] = preg_replace('/([_*\[\]()~`>#+\-=|{}.!\\\\])/', '\\\\$1', $message->getSubject());
7877
}
7978

8079
if (isset($options['photo'])) {

‎src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public function testSendWithMarkdownShouldEscapeSpecialCharacters()
316316

317317
$expectedBody = [
318318
'chat_id' => 'testChannel',
319-
'text' => 'I contain special characters \_ \* \[ \] \( \) \~ \` \> \# \+ \- \= \| \{ \} \. \! to send\.',
319+
'text' => 'I contain special characters \_ \* \[ \] \( \) \~ \` \> \# \+ \- \= \| \{ \} \. \! \\\\ to send\.',
320320
'parse_mode' => 'MarkdownV2',
321321
];
322322

@@ -328,7 +328,7 @@ public function testSendWithMarkdownShouldEscapeSpecialCharacters()
328328

329329
$transport = self::createTransport($client, 'testChannel');
330330

331-
$transport->send(new ChatMessage('I contain special characters _ * [ ] ( ) ~ ` > # + - = | { } . ! to send.'));
331+
$transport->send(new ChatMessage('I contain special characters _ * [ ] ( ) ~ ` > # + - = | { } . ! \\ to send.'));
332332
}
333333

334334
public function testSendPhotoWithOptions()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.