From 622e725921b19c83d3c8ba43c8a67bf1737acf75 Mon Sep 17 00:00:00 2001 From: Rohit Sehgal Date: Sun, 21 Jun 2020 12:36:51 +0530 Subject: [PATCH] Fix #47, HTML escaping, Version upgrade (#48) --- EmailsToTelegramService/pom.xml | 9 ++++++++- .../EmailsToTelegramService/SendTelegramMessage.java | 11 +++++++++-- TrashEmailService/pom.xml | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/EmailsToTelegramService/pom.xml b/EmailsToTelegramService/pom.xml index 9c2790b..a0c2db8 100644 --- a/EmailsToTelegramService/pom.xml +++ b/EmailsToTelegramService/pom.xml @@ -10,7 +10,7 @@ io.github.trashemail imapclientservice - 2.0.0 + 2.0.1 EmailsToTelegramService IMAP Client background services for TrashEmail @@ -57,6 +57,13 @@ jsoup 1.13.1 + + + org.apache.commons + commons-text + 1.4 + + diff --git a/EmailsToTelegramService/src/main/java/io/github/trashemail/EmailsToTelegramService/SendTelegramMessage.java b/EmailsToTelegramService/src/main/java/io/github/trashemail/EmailsToTelegramService/SendTelegramMessage.java index 42bc4ec..45b1f23 100644 --- a/EmailsToTelegramService/src/main/java/io/github/trashemail/EmailsToTelegramService/SendTelegramMessage.java +++ b/EmailsToTelegramService/src/main/java/io/github/trashemail/EmailsToTelegramService/SendTelegramMessage.java @@ -14,6 +14,8 @@ import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; +import org.apache.commons.text.StringEscapeUtils; + import java.util.ArrayList; import java.util.List; @@ -59,11 +61,16 @@ public void sendMessage(String message, long chatId, String filename) { imapClientServiceConfig.getTelegram().getBotToken() + "/sendMessage"; - ArrayList messageChunks = chunks(message); + String escapedMessage = StringEscapeUtils.escapeHtml4(message); + ArrayList messageChunks = chunks(escapedMessage); + for (int i = 0; i < messageChunks.size(); i++) { TelegramMessage request = new TelegramMessage( chatId, - messageChunks.get(i)); + messageChunks.get(i), + "HTML"); + + log.debug(request.toString()); ResponseEntity response = restTemplate.postForEntity( telegramURI, diff --git a/TrashEmailService/pom.xml b/TrashEmailService/pom.xml index adc41e0..bda5831 100644 --- a/TrashEmailService/pom.xml +++ b/TrashEmailService/pom.xml @@ -10,7 +10,7 @@ io.github trashemail - 2.0.0 + 2.0.1 Trashemail Springboot miscroservice - heart of Telegram @trashemail_bot