Skip to content

Commit

Permalink
Fix #47, HTML escaping, Version upgrade (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosehgal authored Jun 21, 2020
1 parent e6b0a8b commit 622e725
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 8 additions & 1 deletion EmailsToTelegramService/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>io.github.trashemail</groupId>
<artifactId>imapclientservice</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<name>EmailsToTelegramService</name>
<description>IMAP Client background services for TrashEmail</description>

Expand Down Expand Up @@ -57,6 +57,13 @@
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.4</version>
</dependency>

</dependencies>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -59,11 +61,16 @@ public void sendMessage(String message, long chatId, String filename) {
imapClientServiceConfig.getTelegram().getBotToken() +
"/sendMessage";

ArrayList<String> messageChunks = chunks(message);
String escapedMessage = StringEscapeUtils.escapeHtml4(message);
ArrayList<String> 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,
Expand Down
2 changes: 1 addition & 1 deletion TrashEmailService/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>io.github</groupId>
<artifactId>trashemail</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<name>Trashemail</name>
<description>Springboot miscroservice - heart of Telegram @trashemail_bot</description>
<distributionManagement>
Expand Down

0 comments on commit 622e725

Please sign in to comment.