From 2a0ae093eab01c2f7261494a7edc1be5602adbea Mon Sep 17 00:00:00 2001
From: Kavin <20838718+FireMasterK@users.noreply.github.com>
Date: Sat, 14 Jan 2023 00:29:30 +0000
Subject: [PATCH] Fix escaping URL content that contains special characters.
---
.../me/kavin/piped/utils/ChannelHelpers.java | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/main/java/me/kavin/piped/utils/ChannelHelpers.java b/src/main/java/me/kavin/piped/utils/ChannelHelpers.java
index cee7e79..63ecf0e 100644
--- a/src/main/java/me/kavin/piped/utils/ChannelHelpers.java
+++ b/src/main/java/me/kavin/piped/utils/ChannelHelpers.java
@@ -1,19 +1,14 @@
package me.kavin.piped.utils;
+import com.rometools.rome.feed.synd.*;
import me.kavin.piped.consts.Constants;
import me.kavin.piped.utils.obj.db.Channel;
import me.kavin.piped.utils.obj.db.Video;
import okhttp3.Request;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
import org.hibernate.StatelessSession;
-import com.rometools.rome.feed.synd.SyndContent;
-import com.rometools.rome.feed.synd.SyndContentImpl;
-import com.rometools.rome.feed.synd.SyndEntry;
-import com.rometools.rome.feed.synd.SyndEntryImpl;
-import com.rometools.rome.feed.synd.SyndPerson;
-import com.rometools.rome.feed.synd.SyndPersonImpl;
-
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -75,7 +70,7 @@ public class ChannelHelpers {
SyndPerson person = new SyndPersonImpl();
SyndContent content = new SyndContentImpl();
SyndContent thumbnail = new SyndContentImpl();
-
+
person.setName(channel.getUploader());
person.setUri(Constants.FRONTEND_URL + "/channel/" + channel.getUploaderId());
entry.setAuthors(Collections.singletonList(person));
@@ -87,12 +82,17 @@ public class ChannelHelpers {
String contentText = String.format("Title: %s\nViews: %d\nId: %s\nDuration: %d\nIs YT Shorts: %b", video.getTitle(), video.getViews(), video.getId(), video.getDuration(), video.isShort());
content.setValue(contentText);
- String thumbnailContent = String.format("", Constants.FRONTEND_URL + "/watch?v=" + video.getId(), video.getThumbnail());
+ String thumbnailContent = StringEscapeUtils.escapeXml11(
+ String.format("