Escape title
This commit is contained in:
parent
e97bea90e9
commit
4dcd67f71b
@ -43,7 +43,7 @@ namespace RSSBot {
|
||||
{
|
||||
string url = args[1].Value;
|
||||
long chatId = message.Chat.Id;
|
||||
RssBotFeed feed = new RssBotFeed(url);
|
||||
RssBotFeed feed = new(url);
|
||||
|
||||
await Bot.BotClient.SendChatActionAsync(message.Chat, ChatAction.Typing);
|
||||
|
||||
@ -196,7 +196,7 @@ namespace RSSBot {
|
||||
|
||||
List<RssBotFeed> feeds = Bot.RssBotFeeds.Where(x => x.Subs.Contains(chatId)).ToList();
|
||||
|
||||
StringBuilder text = new StringBuilder();
|
||||
StringBuilder text = new();
|
||||
if (feeds.Count < 1) {
|
||||
text.Append("❌ Keine Feeds abonniert.");
|
||||
} else {
|
||||
@ -236,6 +236,7 @@ namespace RSSBot {
|
||||
string postTitle = "Kein Titel";
|
||||
if (!string.IsNullOrWhiteSpace(entry.Title)) {
|
||||
postTitle = Utils.StripHtml(entry.Title);
|
||||
postTitle = Utils.EscapeHtml(postTitle);
|
||||
}
|
||||
|
||||
string postLink = feed.MainLink;
|
||||
|
9
Utils.cs
9
Utils.cs
@ -7,13 +7,20 @@ using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace RSSBot {
|
||||
public static class Utils {
|
||||
private static readonly Regex RegexHtml = new Regex("<.*?>");
|
||||
private static readonly Regex RegexHtml = new("<.*?>");
|
||||
|
||||
public static string StripHtml(string input)
|
||||
{
|
||||
return RegexHtml.Replace(input, string.Empty).Trim();
|
||||
}
|
||||
|
||||
public static string EscapeHtml(string input)
|
||||
{
|
||||
input = input.Replace("<", "<");
|
||||
input = input.Replace(">", ">");
|
||||
return input;
|
||||
}
|
||||
|
||||
private static string CleanRss(string input)
|
||||
{
|
||||
string[] replacements = {
|
||||
|
Loading…
Reference in New Issue
Block a user