Merge pull request #504 from TeamPiped/feeds-encoding

Don't escape entire HTML, just the URL.
This commit is contained in:
Kavin 2023-01-14 14:38:12 +00:00 committed by GitHub
commit 5236c9a3cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -278,11 +278,11 @@ public class FeedHandlers {
entries.add(entry); entries.add(entry);
if (filtered.size() == 1) { if (filtered.size() == 1) {
feed.setTitle(channel.getUploader()); feed.setTitle("Piped - " + channel.getUploader());
SyndImage channelIcon = new SyndImageImpl(); SyndImage channelIcon = new SyndImageImpl();
channelIcon.setLink(Constants.FRONTEND_URL + "/channel/" + channel.getUploaderId()); channelIcon.setLink(Constants.FRONTEND_URL + "/channel/" + channel.getUploaderId());
channelIcon.setTitle(channel.getUploader()); channelIcon.setTitle(channel.getUploader());
channelIcon.setUrl(channel.getUploaderAvatar()); channelIcon.setUrl(rewriteURL(channel.getUploaderAvatar()));
feed.setIcon(channelIcon); feed.setIcon(channelIcon);
feed.setImage(channelIcon); feed.setImage(channelIcon);
} }

View File

@ -16,6 +16,8 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static me.kavin.piped.utils.URLUtils.rewriteURL;
public class ChannelHelpers { public class ChannelHelpers {
public static boolean isValidId(String id) { public static boolean isValidId(String id) {
@ -82,11 +84,10 @@ 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()); 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); content.setValue(contentText);
String thumbnailContent = StringEscapeUtils.escapeXml11( String thumbnailContent =
String.format("<div xmlns=\"http://www.w3.org/1999/xhtml\"><a href=\"%s\"><img src=\"%s\"/></a></div>", String.format("<div xmlns=\"http://www.w3.org/1999/xhtml\"><a href=\"%s\"><img src=\"%s\"/></a></div>",
Constants.FRONTEND_URL + "/watch?v=" + video.getId() Constants.FRONTEND_URL + "/watch?v=" + video.getId(),
, video.getThumbnail() StringEscapeUtils.escapeXml11(rewriteURL(video.getThumbnail()))
)
); );
thumbnail.setType("xhtml"); thumbnail.setType("xhtml");
thumbnail.setValue(thumbnailContent); thumbnail.setValue(thumbnailContent);